|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
predict.glm & newdataHi all - I'm stumped by the following mdl <- glm(resp ~ . , data = df, family=binomial, offset = ofst) WORKS yhat <- predict(mdl) WORKS yhat <- predict(mdl,newdata = df) FAILS Error in drop(X[, piv, drop = FALSE] %*% beta[piv]) : subscript out of bounds I've tried without offset, quoting binomial. The offset variable ofst IS in df. Previous postings indicate possible names(df) problems (renaming factor levels?) but I'm using the same data.frame for the newdata option. Thank you in advance for any pointers. Tom. _________________________________________________________________ Going green? See the top 12 foods to eat organic. 1N1653A [[alternative HTML version deleted]] ______________________________________________ R-help@... mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
|
|
Re: predict.glm & newdataHi,
could it be the "newdata" argument? When I run predict with the newdata argument, I get an error message - a different one though. The second reason might be that your dataset is named df, which is defined as a function an may produce problems. Try renaming the dataset. yhat=predict(reg1,newdata=x2) x1=seq(1:100) r.norm1=rnorm(100,0,20) x1=r.norm1+x1 x2=x1*2 r.norm2=rnorm(200,0,20) x2=r.norm2+x2 reg1=glm(y1~x1,binomial) yhat=predict(reg1) ##prediction works fine yhat=predict(reg1,newdata=x2) ##gives error message because of "newdata" >Error in eval(predvars, data, env) : numeric 'envir' arg not of length one yhat=predict(reg1,data=x2) ##works fine ##using offset ofst=rep(0.5,100) reg1=glm(y1~x1,binomial,offset=ofst) yhat=predict(reg1) yhat1=predict(reg1,newdata=x2) ##gives error message yhat2=predict(reg1,data=x2) ##works fine ------------------------- cuncta stricte discussurus ------------------------- -----Ursprüngliche Nachricht----- Von: r-help-bounces@... [mailto:r-help-bounces@...] Im Auftrag von Tom Guston Gesendet: Friday, April 04, 2008 1:29 PM An: r-help@... Betreff: [R] predict.glm & newdata Hi all - I'm stumped by the following mdl <- glm(resp ~ . , data = df, family=binomial, offset = ofst) WORKS yhat <- predict(mdl) WORKS yhat <- predict(mdl,newdata = df) FAILS Error in drop(X[, piv, drop = FALSE] %*% beta[piv]) : subscript out of bounds I've tried without offset, quoting binomial. The offset variable ofst IS in df. Previous postings indicate possible names(df) problems (renaming factor levels?) but I'm using the same data.frame for the newdata option. Thank you in advance for any pointers. Tom. _________________________________________________________________ Going green? See the top 12 foods to eat organic. 1N1653A [[alternative HTML version deleted]] ______________________________________________ R-help@... mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@... mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
|
|
Re: predict.glm & newdataYou could just say:
yhat=predict(reg1,x2) the function predict will assing x2 to 'newdata' by default. thanks
Yasir H. Kaheil
Columbia University |
|
|
tukey biweight of vectorDear list,
I have a vector of readings of length 4640 length(int) [1] 4640 I would like to calculate Tukey´s biweight using the tbrm() function for the first ten values, the next ten values,etc and store it in another vector of length 464. Can anyone help me? Thanks in advance David ______________________________________________ R-help@... mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
|
|
Re: tukey biweight of vectorapply(matrix(int,nr=10),2,trbm)
?apply -- Bert Gunter Genentech Nonclinical Statistics -----Original Message----- From: r-help-bounces@... [mailto:r-help-bounces@...] On Behalf Of DAVID ARTETA GARCIA Sent: Monday, May 05, 2008 8:19 AM To: r-help@... Subject: [R] tukey biweight of vector Dear list, I have a vector of readings of length 4640 length(int) [1] 4640 I would like to calculate Tukey´s biweight using the tbrm() function for the first ten values, the next ten values,etc and store it in another vector of length 464. Can anyone help me? Thanks in advance David ______________________________________________ R-help@... mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@... mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
| Free embeddable forum powered by Nabble | Forum Help |