I am trying to predict follow-up time using several survival models, both parametric and semi-parametric. I achieve it for semi parametric models using predict.coxph function in R using type = "expected" as indicated in help. However, for parametric models, this option doesn't exist for the predict.survreg function. Is there any other option? Maybe using rms package?
Related
I am using regsubsets method for linear regression and came across step() method for selecting columns for logistic regression methods.
I am not sure whether we can use regsubsets or steps for Poisson regression. It will be helpful if there is a method to find the best subsets for Poisson regression in R programming.
From here it looks like
step() (base R: works on glm objects -> includes Poisson regression models)
bestglm package
glmulti package
Possibly others.
Be prepared for the GLM (Poisson etc.) case to be much slower than the analogous problem for Gaussian responses (OLS/lm).
Suppose I fit AR(p) model using R arima function from stats package. I fit it using a sample x_1,...,x_n. In theory, when predicting x_{n+1} using this model, it needs an access x_n,...x_{n-p}.
How does the model know which observation I want to predict? What if I wanted to actually predict x_n based on x_{n-1},...,x_{n-p-1} and how my code would differ in this case? Can I make in-sample forecasts, similar to Python's functionality?
If my questions imply that I think about forecasting in a wrong way, please kindly correct my understanding of the subject.
I am doing a comparative analysis, and my response variables are 0 or 1, therefore I need to do a phylogenetically-corrected analysis with a binomial error distribution. I used the PGLMM_compare function from the phyr package (https://rdrr.io/github/daijiang/phyr/man/pglmm_compare.html) to create a full model with all of my variables, but MuMin does not support this output as a 'global model', therefore I cannot dredge it. I am looking for a way to find the best models and possibly perform model averaging from these, however it seems that these packages are not compatible. It would be difficult to create all the models by hand, since I have ~8 explanatory variables. Is there any way of dredging a phylogenetic model with binomial error structure? Thanks in advance.
You would need to implement at least the following methods for dredge and model.avg to work with pglmm_compare:
nobs.pglmm_compare(object, ...)
logLik.pglmm_compare(object, ...)
coef.pglmm_compare(object, ...)
coefTable.pglmm_compare(model, ...)
I am trying to fit a transfer function model using R in order to apply the fitted model to a validation set of data, because SPSS doesn't allow me to (or I don't know how to) compute point forecasts just like the function Arima() from forecast package does. It does let me apply the model, but it does not use the dependet variable's lagged values, that's why I am trying R.
Anyone know how I could get those type of "updated" or validation forecasts using the arimax() function? I am not looking for the following type of predictions:
predict(vixari011, n.ahead=12)
But rather these:
Arima(test$VIX, model = vixari)
From what I have been reading there is no prediction function for the arimax() function, any ideas about how I could forecast to evaluate point-by-point performance? I can just think of computing manually using a spreadsheet...
I had the same problem. I know this post is old but this can help someone.
I used this it worked just fine
forecast(fitted(arimax_ts_model), h=11)
I've been using the caret package in R to run some boosted regression tree and random forest models and am hoping to generate prediction intervals for a set of new cases using the inbuilt cross-validation routine.
The trainControl function allows you to save the hold-out predictions at each of the n-folds, but I'm wondering whether unknown cases can also be predicted at each fold using the built-in functions, or whether I need to use a separate loop to build the models n-times.
Any advice much appreciated
Check the R package quantregForest, available at CRAN. It can easily calculate prediction intervals for random forest models. There's a nice paper by the author of the package, explaining the backgrounds of the method. (Sorry, I can't say anything about prediction intervals for BRT models; I'm looking for them by myself...)