[R] Discrepant lm() and survreg() standard errors with weighted fits
Kyle Penner
kpenner at as.arizona.edu
Mon Feb 24 23:20:55 CET 2014
Hi,
I have some measurements and their uncertainties. I'm using an
uncensored subset of the data for a weighted fit (for now---I'll do a
fit to the full, censored, dataset when I understand the results).
survreg() reports a much smaller standard error for the model
parameter than lm(), but only when I use weights. Am I missing
something? Here is what I'm doing:
atten = read.table('http://hobo.as.arizona.edu/~kpenner/temp/r_help')
uvlog = atten[,1]
halog = atten[,2]
haerrlog = atten[,3]
eventcode_det = seq(1,1,length=length(halog))
# do 2 basic unweighted fits, one using lm(), one using survreg()
basic = lm(halog~uvlog-1)
surv_basic = survreg(Surv(time=halog, event=eventcode_det)~uvlog-1,
dist='gaussian', init=c(3.33*1.8/9.97))
summary(basic)$coef[2]
summary(surv_basic)$table[1,2]
# hey look they agree
basic_weight = lm(halog~uvlog-1, weights=1/(haerrlog^2))
surv_basic_weight = survreg(Surv(time=halog,
event=eventcode_det)~uvlog-1, dist='gaussian', init=c(3.33*1.8/9.97),
weights=1/(haerrlog^2), robust=T)
summary(basic_weight)$coef[2]
summary(surv_basic_weight)$table[1,2]
# if I leave off robust=T, survreg() SE is still much smaller
Thanks,
Kyle
More information about the R-help
mailing list