As stated in the comments, I ended up using the method given by @Rootless17b. I don't think this is the answer I was looking for (see comment) but it worked nonetheless. I recently stumbled upon Gerds et al. riskRegression package and in particular the predictCox function. I have not explored it in depth but I think this does what I wanted.
Yes, you can do whatever you want to forecast, even though it might not explain the relationship.
If you're interested in forecasting, then you will measure the performance of your model based on it's forecasting power. This indeed might not explain any relationship at all.
I don't know what te is, I have set it to 1:10.
In the first case using glm the function predict.glm needs a data frame with a column named like the predictor variable.
In the second case the return of predict.smooth.spline is a list with x as input data (vector) and y as fitted values (also a vector)..meaning a list of vectors.
Here is my working example ...
I believe you should use the prediction interval. You wrote that you care "about the cost to purchase a 200kg refrigerator" so you care about the distribution of Y for X=200, not the distribution of the mean/average Y for X=200. To know that you are getting a good deal, you need to know the distribution of costs.
If your KPI was the average cost ...
In your logistic model with year, time is assumed to act linearly on the logodds. With an additive model estimated with gam, a smooth action replaces the linear action, represented with a spline function. That gives a nice test on the assumption of linearity.
But, you want to use the model for extrapolation? A spline model will not help much with that ... ...
This is however based on the assumption that each subject will die one day (does not have to be during study, those are so called censored data) and that the risk of dying is increasing in time (i.e. survival function is decreasing).
Both of these "assumptions" are not necessary to perform survival analysis. In fact, they are not assumptions of ...
This Answer is exploratory. If you knew for sure from the beginning of your experiment that all 50 patients were infected, so that a 'gold standard' tests would have given 10 positive results for every one of the 50 patients,
then I don't see how you could get the reported results as I understand
If all patients were infected from the start, ...
I found the explanation in the textbook and the other answers here (and Confusion in regression function derivation and Confused by Derivation of Regression Function) inadequate, so I decided to add my own version. I know many readers of the book and this website will not have a background in measure theory but for me it makes everything clearer. Some of the ...
You can get survival estimates for the 4 hypothetical subjects at specific times from your csurv object.
summary(csurv, time = c(1,2,3,4))
will give you the survival estimates at timepoint 1 2 3 and 4. By calculating 1-survival you can get the cummulative hazard at timepoint 1 2 3 and 4.
An alternative would be to get the values manually from the csurv ...
I believe your proposed procedure is not valid. Here's a quick simulation to demonstrate. Below, we make the simulation as simple as possible, and the procedure still fails:
We'll generate Weibull distributed data, and use a Weibull model to fit. We'll check the fitted parameters are accurate.
We'll have no censoring.
We'll use lots of samples.
Something along these lines, where you would of course probably also want to plot the original time series etc.
y <- arima.sim(list(order=c(1,0,0), ar=0.9), n=120)
y.is <- y[1:100] # in-sample und ...
y.oos <- y[101:120] # out-of-sample
reg.AR1 <- arima(y.is, order=c(1,0,0))
fore.AR1 <- predict(reg.AR1, n.ahead=20)$pred
I think that you could try to use the LSTM, which is a deep neural network from a particular class of networks called Recurrent Neural Networks. The LSTM is quite powerful for forecasting several types of time series.
You could start with this tutorial from TensorFlow: