Displaying 20 results from an estimated 4000 matches similar to: "predict with model (rms package)"
2011 Mar 09
2
rms: getting adjusted R^2 from ols object
How can I extract the adjusted R^2 value from an ols object (using rms package)?
library(rms)
x <- rnorm(10)
y <- x + rnorm(10)
ols1 <- ols(y ~ x)
Typing "ols1" displays adjusted R^2 among other things, but how can I
assign it to a variable? I tried str(ols1) but couldn't see where to
go from there.
Thanks,
Mark Seeto
2009 Sep 30
1
rcs fits in design package
Hi all,
I have a vector of proportions (post_op_prw) such that
>summary(amb$post_op_prw)
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
0.0000 0.0000 0.0000 0.3985 0.9134 0.9962 1.0000
> summary(cut2(amb$post_op_prw,0.0001))
[0.0000,0.0001) [0.0001,0.9962] NA's
1904 1672 1
2009 Sep 08
2
Very basic question regarding plot.Design...
Hello ALL!
I have a problem to plot factor (lets say gender) as a line, or at least
both line and point, from ols model:
ols1 <- ols(Y ~ gender, data=dat, x=T, y=T)
plot(ols1, gender=NA, xlab="gender", ylab="Y",
ylim=c(5,30), conf.int=FALSE)
If I convert gender into discrete numeric predictor, and use
forceLines=TRUE, plot is not nice and true, since it shows values
2011 Apr 12
2
Model formula for ols function (rms package)
Dear R help,
I'm having some trouble with model formulas for the ols function in
the rms package. I want to have two variables represented as
restricted cubic splines, and also include an interaction as a product
of linear terms, but I get an error message.
library(rms)
d <- data.frame(x1 = rnorm(50), x2 = rnorm(50), y = rnorm(50))
ols(y ~ rcs(x1,3) + rcs(x2,3) + x1*x2, data=d)
Error in
2009 Dec 02
1
Incorporating the results of White's HCCM into a linear regression:
Using hccm() I got a heteroscedasticity correction factor on the diagonal of
the return matrix, but I don't know how to incorporate this into my linear
model:
METHOD 1:
> OLS1 <- lm(formula=uer92~uer+low2+mlo+spec+degree+hit)
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.0623377 0.0323461 -1.927 0.057217 .
uer 0.2274742 0.0758720
2012 Apr 19
2
Gls function in rms package
Dear R-help,
I don't understand why Gls gives me an error when trying to fit a
model with AR(2) errors, while gls (from nlme) does not. For example:
library(nlme)
library(rms)
set.seed(1)
d <- data.frame(x = rnorm(50), y = rnorm(50))
gls(y ~ x, data=d, correlation = corARMA(p=2)) #This works
Gls(y ~ x, data=d, correlation = corARMA(p=2)) # Gives error
# Error in
2005 Feb 24
2
a question about function eval()
Hi,
I have a question about the usage of eval(). Wonder if any experienced user can help me out of it.
I use eval() in the following function:
semireg.pwl <- function(coef.s=rnorm(1),coef.a=rnorm(1),knots.pos=knots.x,knots.ini.val=knots.val){
knotn <- length(knots.pos)
def.par.env <- sys.frame(1)
print(def.par.env)
print(environment(coef.s))
tg <- eval( (parse(text=
2010 Aug 10
1
Multiple imputation, especially in rms/Hmisc packages
Hello, I have a general question about combining imputations as well as a
question specific to the rms and Hmisc packages.
The situation is multiple regression on a data set where multiple
imputation has been used to give M imputed data sets. I know how to get
the combined estimate of the covariance matrix of the estimated
coefficients (average the M covariance matrices from the individual
2010 Jun 29
1
Model validation and penalization with rms package
I?ve been using Frank Harrell?s rms package to do bootstrap model
validation. Is it the case that the optimum penalization may still
give a model which is substantially overfitted?
I calculated corrected R^2, optimism in R^2, and corrected slope for
various penalties for a simple example:
x1 <- rnorm(45)
x2 <- rnorm(45)
x3 <- rnorm(45)
y <- x1 + 2*x2 + rnorm(45,0,3)
ols0 <- ols(y
2002 May 11
2
Bug on Mac version of lm()?
Dear Mac users,
Hi, as you might have probably read the thread of
"[R] Rsquared in summary(lm)" on May 10, it seems that Mac version of
lm() seem to be working incorrectly.
I enclose the script to produce the result both for lm() and manual
calculation for a simple regression. Could you run the script and
report with the version of R, so I don't have to go through every
builds
2009 Oct 23
2
interpretation of RCS 'coefs' and 'knots'
Hi,
I have fit a series of ols() models, by group, in this manner:
l <- ols(y ~ rcs(x, 4))
... where the series of 'x' values in each group is the same, however knots
are not always identical between groups. The result is a table of 'coefs'
derived from the ols objects, by group:
group Intercept top top' top''
1 6.864 0.01 2.241 -2.65
2010 Jun 07
1
ols function in rms package
Hello,
I have a couple of questions about the ols function in Frank Harrell's rms
package.
Is there any way to specify variables by their column number in the data
frame rather than by the variable name?
For example,
library(rms)
x1 <- rnorm(100, 0, 1)
x2 <- rnorm(100, 0, 1)
x3 <- rnorm(100, 0, 1)
y <- x2 + x3 + rnorm(100, 0, 5)
d <- data.frame(x1, x2, x3, y)
rm(x1, x2, x3,
2013 Feb 27
1
Finding the knots in a smoothing spline using nknots
Hi r-helpers.
Please forgive my ignorance, but I would like to plot a smoothing spline
(smooth.spline) from package "stats", and show the knots in the plot, and I
can't seem to figure out where smooth.spline has located the knots (when I
use nknots). Unfortunately, I don't know a lot about splines, but I know
that they provide me an easy way to estimate the location of local
2010 Jun 11
1
Documentation of B-spline function
Goodmorning,
This is a documentation related question about the B-spline function in R.
In the help file it is stated that:
"df degrees of freedom; one can specify df rather than knots; bs() then chooses df-degree-1 knots at suitable quantiles of x (which will ignore missing values)."
So if one were to specify a spline with 6 degrees of freedom (and no intercept) then a basis
2024 Jul 16
2
Automatic Knot selection in Piecewise linear splines
>>>>> Anupam Tyagi
>>>>> on Tue, 9 Jul 2024 16:16:43 +0530 writes:
> How can I do automatic knot selection while fitting piecewise linear
> splines to two variables x and y? Which package to use to do it simply? I
> also want to visualize the splines (and the scatter plot) with a graph.
> Anupam
NB: linear splines, i.e. piecewise
2008 May 01
1
Optimal knot locations for splines
Suppose I have two variables, x and y. For a fixed number of knots, I want
to create a spline transformation of x such that a loss function is
minimized. Presumably, this loss function would be least squares, i.e. sum
(f(x)-y)^2. The spline transformations would be linear, quadratic or
cubic. I know I can solve this problem using some optimization function in
R, but I was wondering if anyone
2013 Jan 28
2
Why are the number of coefficients varying? [mgcv][gam]
Dear List,
I'm using gam in a multiple imputation framework -- specifying the knot
locations, and saving the results of multiple models, each of which is
fit with slightly different data (because some of it is predicted when
missing). In MI, coefficients from multiple models are averaged, as are
variance-covariance matrices. VCV's get an additional correction to
account for how
2010 Nov 17
1
where are my pspline knots?
Hi All,
I am trying to figure out how to get the position of the knots in a pspline used in a cox model.
my.model = coxph(Surv(agein, ageout, status) ~ pspline(x), mydata) # x being continuous
How do I find out where the knot of the spline are? I would like to know to figure out how many cases are there between each knot.
Best,
Federico
--
Federico C. F. Calboli
Department of Epidemiology
2003 May 08
2
natural splines
Apologies if this is this too obscure for R-help.
In package splines, ns(x,,knots,intercept=TRUE) produces an n by K+2
matrix N, the values of K+2 basis functions for the natural splines with K
(internal) knots, evaluated at x. It does this by first generating an
n by K+4 matrix B of unconstrained splines, then postmultiplying B by
H, a K+4 by K+2 representation of the nullspace of C (2 by K+4),
2024 Jul 26
1
Automatic Knot selection in Piecewise linear splines
dear all,
I apologize for my delay in replying you. Here my contribution, maybe
just for completeness:
Similar to "earth", "segmented" also fits piecewise linear relationships
with the number of breakpoints being selected by the AIC or BIC
(recommended).
#code (example and code from Martin Maechler previous email)
library(segmented)
o<-selgmented(y, ~x, Kmax=20,