[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


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))


# 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)


# if I leave off robust=T, survreg() SE is still much smaller



More information about the R-help mailing list