Displaying 4 results from an estimated 4 matches for "thislm".
2012 Dec 06
1
scope, lme, ns, nlme, splines
...string)). But is there not a
more elegant solution?
set.seed(5)
junk<-data.frame(x=rnorm(100))
junk$y<-junk$x + rnorm(nrow(junk))
junk$idvar<- factor(sample(LETTERS[1:10], size=nrow(junk), replace=TRUE))
library("nlme")
library(splines)
fitfunction<-function(splineDF=1) {
thislm<-lm( y ~ ns(x, df=splineDF), data= junk)
thislm
cat("finished thislm\n")
thislme<-lme(
fixed= y ~ ns(x, df=splineDF)
, random= ~ 1 | idvar
, data= junk)
thislme
}
fitfunction()
KLUDGEfit<-function(splineDF=2) {
thislm<-lm( y ~ ns(x, df=splineDF), data= junk...
2004 Nov 30
4
adding regression curve to xyplot
...2
33.89501 36.74620
As expected, predict gives two values. But inside xyplot() predict gives
300 values:
> xyplot(t~s|factor(lonLabels[whichLon100])*factor(latLabels[whichLat100]),
+ data=P100,pch=".",
+ panel=function(x,y,...){panel.xyplot(x,y,...)
+ thislm <- lm(x~y)
+ print(thislm)
+ newt <- range(P100$t)
+ print(newt)
+ news <-
as.vector(predict(thislm,newdata=data.frame(t=newt)))
+ print(news)
+ llin...
2009 Nov 11
1
loop through variable names
...) inside the loop.
For instance:
thesevars<-names(environmental)
environmental$ToyOutcome<-rnorm(nrow(environmental))
tableOfResults<-data.frame(var=thesevars)
tableOfResults$Beta<- NA
rownames(tableOfResults)<-thesevars
for( thisvar in thesevars) {
thiscommand<- paste("thislm <- lm( ToyOutcome ~ ", thisvar, ", data=environmental)")
eval(parse(text=thiscommand))
tableOfResults[thisvar, "Beta"] <- coef(thislm)[thisvar]
}
print(tableOfResults)
Note that it's not always as simple a task as in this example. Within the loop, I might fi...
2007 Jan 26
1
bootstrap bca confidence intervals for large number of statistics in one model; library("boot")
...alues at 50 levels of the predictor.
set.seed(1234567)
x<-runif(150)
y<-2/3 + pi * x^2 + runif(length(x))/2
plot(x,y)
DAT<-data.frame(x,y)
NEWDATA<-data.frame(x=seq(min(x), max(x), length=50))
library('boot')
myfn<-function(data, whichrows) {
TheseData<-data[whichrows,]
thisLM<-lm( y~poly(x,2), data=TheseData)
thisFit<-predict(thisLM, newdata=NEWDATA)
c(
coef(summary(thisLM))[,"Estimate"]
, thisFit)
}
bootObj<-boot( data=DAT, statistic=myfn, R=1000 )
names(bootObj)
dim(bootObj$t)
sofar<-t(sapply( 1:ncol(bootObj$t), function(thiscolumn) boot.ci...