カテゴリカルデータで制約付の回帰。 結局結論をまとめると y=a1*x1+a2*x2+a3*x3+Cで、 x=[1,2,3], x1,x2,x3ダミー変数のとき(0,1)、 a<-NULL a[1]<-100 a[2]<-300 a[3]<-400 aa<-rbinom(size=2,1000,prob=0.5)+1 y<-a[aa]+rnorm(1000) x<-factor(aa) lm(y~factor(x),list(x = contr.sum)) 結果 Call: lm(formula = y ~ x, contrasts = list(x = contr.sum)) Coefficients: (Intercept) x1 x2 266.69 -166.68 33.33 とすれば、回帰係数a1:x1とa2:x2が求められる。a3=(0-a1-a2)となる。 一方、 lm(y~f