similar to: predict

Displaying 20 results from an estimated 10000 matches similar to: "predict"

2018 Apr 27
5
predict.glm returns different results for the same model
Hi all, Very surprising (to me!) and mystifying result from predict.glm(): the predictions vary depending on whether or not I use ns() or splines::ns(). Reprex follows: library(splines) set.seed(12345) dat <- data.frame(claim = rbinom(1000, 1, 0.5)) mns <- c(3.4, 3.6) sds <- c(0.24, 0.35) dat$wind <- exp(rnorm(nrow(dat), mean = mns[dat$claim + 1], sd = sds[dat$claim + 1])) dat <-
2011 Jan 28
6
User error in calling predict/model.frame
I want to predict values from an existing lm (linear model, e.g. lm.obj) result in R using a new set of predictor variables (e.g. newdata). However, it seems that because my linear models was made by calling scale() on the target predictor that predict exits with an error, "Error in scale(xxA, center = 9.7846094491829, scale = 0.959413568556403) : object 'xxA' not found". By
2010 Jan 16
2
predict.glm
Hi, See below I reply your message for <https://stat.ethz.ch/pipermail/r-help/2008-April/160966.html>[R] predict.glm & newdata posted on Fri Apr 4 21:02:24 CEST 2008 You say it ##works fine but it does not: if you look at the length of yhat2, you will find 100 and not 200 as expected. In fact predict(reg1, data=x2) gives the same results as predict(reg1). So I am still looking for
2006 May 27
1
Recommended package nlme: bug in predict.lme when an independent variable is a polynomial (PR#8905)
Full_Name: Renaud Lancelot Version: Version 2.3.0 (2006-04-24) OS: MS Windows XP Pro SP2 Submission from: (NULL) (82.239.219.108) I think there is a bug in predict.lme, when a polynomial generated by poly() is used as an explanatory variable, and a new data.frame is used for predictions. I guess this is related to * not * using, for predictions, the coefs used in constructing the orthogonal
2007 May 31
1
predict.nls - gives error but only on some nls objects
Dear list, I have encountered a problem with predict.nls (Windows XP, R.2.5.0), but I am not sure if it is a bug... On the nls man page, an example is: DNase1 <- subset(DNase, Run == 1) fm2DNase1 <- nls(density ~ 1/(1 + exp((xmid - log(conc))/scal)), data = DNase1, start = list(xmid = 0, scal = 1)) alg = "plinear", trace =
2008 Apr 04
2
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
2012 Mar 27
4
Help on predict.lm
Hello, I'm new here, but will try to be as specific and complete as possible. I'm trying to use “lm“ to first estimate parameter values from a set of calibration measurements, and then later to use those estimates to calculate another set of values with “predict.lm”. First I have a calibration dataset of absorbance values measured from standard solutions with known concentration of
2010 Jul 21
2
Variance of the prediction in the linear regression model (Theory and programming)
Hi, folks, Here are the codes: ############## y=1:10 x=c(1:9,1) lin=lm(log(y)~x) ### log(y) is following Normal distribution x=5:14 prediction=predict(lin,newdata=x) ##prediction=predict(lin) ############### 1. The codes do not work, and give the error message: Error in eval(predvars, data, env) : numeric 'envir' arg not of length one. But if I use the code after the pound sign, it
2009 Jul 13
2
graph: axis label font
Hi, excuse me for my english, i am using R on windows and i have to do several graphs with axis labels and the axis text thicks has a specified font type, (Arial) and a specified font size. How can i do these? Thank you in advance -- View this message in context: http://www.nabble.com/graph%3A-axis-label-font-tp24463974p24463974.html Sent from the R help mailing list archive at Nabble.com.
2008 Apr 12
2
Predict Function
Hi all - my first time here and am having an issue with the Predict function. I am using a tutorial as a guide, locate here: http://www.ats.ucla.edu/STAT/R/dae/mlogit.htm My code gives this error > newdata1$predicted <- predict(mlogit,newdata=newdata1,type="response") Error in `$<-.data.frame`(`*tmp*`, "predicted", value = c(0.332822934960197, : replacement has
2006 Sep 01
1
difference between ns and bs in predict.glm
I am fittling a spline to a variable in a regression model, I am then using the predict.glm funtion to make some predictions. When I use bs to fit the spline I don't have any problems using the predict.glm function however when I use ns I get the following error: Error in model.frame(formula, rownames, variables, varnames, extras, extranames, : variable lengths differ (found for
2011 Aug 15
3
Help on how to use predict
Dear R-Users My problem is quite simple: I need to use a fitted model to predict the next point (that is, just one single point in a curve). The data was divided in two parts: identification (x and y - class matrix) and validation (xt and yt - class matrix). I don't use all values in x and y but only the 10 nearest points (x[b,] and y[b,]) for each regression (b is a vector with the
2023 Dec 01
1
back tick names with predict function
Also, and possibly more constructively, when you get an error like > CI.c = predict(mod2, data.frame( `plant-density` = x), interval = 'c') # fail Error in eval(predvars, data, env) : object 'plant-density' not found you should check your assumptions. Does "newdata" actually contain a columnn called "plant-density": > head(data.frame( `plant-density`
2010 Jan 19
1
Model frame when LHS is cbind (PR#14189)
The model frame shows the response and predictors in a data frame with nicely labelled columns: fm <- lm(wt~qsec+log(hp)+sqrt(disp), data=mtcars) model.frame(fm) # ok When the left hand side consists of more than one response, those response variables still look good, inside a matrix: fm <- lm(cbind(qsec,hp,disp)~wt, data=mtcars) model.frame(fm)[[1]] # ok A problem arises when
2008 Oct 15
2
apply model predictions over larger area with predict()
Dear all, I have built glm models based on presences/absences and a number of predictor maps and would like to compute habitat suitability based on the modelled coefficients. I thought this is pretty straight forward and wanted to use predict() and supply the new data in a data frame, with one column for each predictor. However, I do get an error msg warning me that the number of rows for
2011 Apr 13
3
predict()
Hi, I am experimenting with the function predict() in two versions of R and the R extension package "survival". library(survival) set.seed(123) testdat=data.frame(otime=rexp(10),event=rep(0:1,each=5),x=rnorm(10)) testfm=as.formula('Surv(otime,event)~x') testfun=function(dat,fm) { predict(coxph(fm,data=dat),type='lp',newdata=dat) } # Under R 2.11.1 and
2011 Apr 13
3
predict()
Hi, I am experimenting with the function predict() in two versions of R and the R extension package "survival". library(survival) set.seed(123) testdat=data.frame(otime=rexp(10),event=rep(0:1,each=5),x=rnorm(10)) testfm=as.formula('Surv(otime,event)~x') testfun=function(dat,fm) { predict(coxph(fm,data=dat),type='lp',newdata=dat) } # Under R 2.11.1 and
2018 Jan 17
1
Assessing calibration of Cox model with time-dependent coefficients
I am trying to find methods for testing and visualizing calibration to Cox models with time-depended coefficients. I have read this nice article <http://journals.sagepub.com/doi/10.1177/0962280213497434>. In this paper, we can fit three models: fit0 <- coxph(Surv(futime, status) ~ x1 + x2 + x3, data = data0) p <- log(predict(fit0, newdata = data1, type = "expected")) lp
2012 Jan 05
1
delete.response leaves response in attribute dataClasses
I posted this one as an R bug (https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14767), but Prof. Ripley says I'm premature, and I should raise the question here. Here's the behavior I assert is a bug: The output from delete.response on a terms object alters the formula by removing the dependent variable. It removes the response from the "variables" attribute and it changes
2023 Dec 01
1
back tick names with predict function
"Thank you Rui. I didn't know about the check.names = FALSE argument. > Another good reminder to always read help, but I'm not sure I understood > what help to read in this case" ?data.frame , of course, which says: "check.names logical. If TRUE then the names of the variables in the data frame are checked to ensure that they are syntactically valid variable names