Young Cho
2007-Aug-28 15:27 UTC
[R] lm.ridge fit with some dummy variables (w/o intercept)
I have columns which sum to one. They are membership dummies, fractions are allowed - I made an example: x <- c( 9.899898,6.9555431,-1.251,0.52000000,0.4800000,0.0000000,-2.2384737, 16.791361,6.8924369,-3.286,0.78846154,0.2115385,0.0000000,-0.4720061, 6.115735,-5.8381799,-1.176,1.00000000,0.0000000,0.0000000,-0.6312019, 10.325595,5.4950276,-2.634,1.00000000,0.0000000,0.0000000,1.4729420, 3.800141,4.1287662,-2.243,0.83000000,0.1700000,0.0000000,,0.9314859, 2.159567,-2.3952889,-4.645,0.53000000,0.0000000,0.4700000,0.7252069, 21.536111,3.3844964,-4.352,1.00000000,0.0000000,0.0000000,-0.9931833, 7.526573,-1.1675684,-5.023,1.00000000,0.0000000,0.0000000,0.2397390, 28.684897,-0.4594389,-3.233,0.89000000,0.0700000,0.0400000,0.6017004, 0.894931,-0.9059129,-5.023,0.04347826,0.0000000,0.9565217,0.6081505) x = matrix(x,ncol=10) x = t(x) colnames(x) = c(''a'',''b'',''c'',''d'',''e'',''f'',''y'')> xa b c d e f y [1,] 9.899898 6.9555431 -1.251 0.52000000 0.4800000 0.0000000 -2.2384737 [2,] 16.791361 6.8924369 -3.286 0.78846154 0.2115385 0.0000000 -0.4720061 [3,] 6.115735 -5.8381799 -1.176 1.00000000 0.0000000 0.0000000 -0.6312019 [4,] 10.325595 5.4950276 -2.634 1.00000000 0.0000000 0.0000000 1.4729420 [5,] 3.800141 4.1287662 -2.243 0.83000000 0.1700000 0.0000000 0.9314859 [6,] 2.159567 -2.3952889 -4.645 0.53000000 0.0000000 0.4700000 0.7252069 [7,] 21.536111 3.3844964 -4.352 1.00000000 0.0000000 0.0000000 -0.9931833 [8,] 7.526573 -1.1675684 -5.023 1.00000000 0.0000000 0.0000000 0.2397390 [9,] 28.684897 -0.4594389 -3.233 0.89000000 0.0700000 0.0400000 0.6017004 [10,] 0.894931 -0.9059129 -5.023 0.04347826 0.0000000 0.9565217 0.6081505> apply(x[,4:6],1,sum)[1] 1 1 1 1 1 1 1 1 1 1 I am trying to use lm.ridge and got some problems on how to extract parameter estimates. E.g., for lambda = 0 case (I cut and pasted at the bottom), how to backout the coef estimate to match them with lm fit? In general, for any given lambda, how to back out the original scale coef estimates?> lm.fit = lm(y~.-a-1,data=data.frame(x),weights=a) > ridge.fit = lm.ridge(y~.-a-1,data=data.frame(x),weights=a,lambda=0) > ridge.fitb c d e f 0.1125886 0.1748883 0.9122774 -5.9140208 1.8784332> lm.fitCall: lm(formula = y ~ . - a - 1, data = data.frame(x), weights = a) Coefficients: b c d e f 0.04232 0.32343 1.36039 -4.67399 3.29727 Thanks so much in advance! Young [[alternative HTML version deleted]]