Displaying 20 results from an estimated 400 matches similar to: "lm function in R"
2001 Apr 27
3
nls question
I have a question about passing arguments to the function f that nlm
minimizes.
I have no problems if I do this:
x<-seq(0,1,.1)
y<-1.1*x + (1-1.1) + rnorm(length(x),0,.1)
fn<-function(p)
{
yhat<-p*x+(1-p)
sum((y-yhat)^2)
}
out<-nlm(fn,p=1.5,hessian=TRUE)
But I would like to define
fn<-function(x,y,p)
{
yhat<-p*x+(1-p)
sum((y-yhat)^2)
}
so
2002 Mar 08
1
Matrix multiplication problem
Dear List,
I am having trouble with some R code I have written to perform
Redundancy Analysis (RDA) on a matrix of species abundance data (Y) and
a matrix of environmental data (X).
RDA is a constrained form of PCA and can be thought of as a PCA of the
fitted values of a regression of each variable in Y on all variables in
X.
For info, the first use of RDA is in:
Rao, C.R, 1964. The use and
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
2012 Mar 08
1
sas retain statement in R or fitting differene equations in NLS
I wish to fit a dynamical model in R and I am running in a problem that
requires some of your wisdom to solve. For SAS users I am searching for
the equivalent of the */retain/ *statement.
For people that want to read complicated explanations to help me:
I have a system of two equations written as difference equations here.
To boil it down. I have a dataframe with three variables y, X1, X2
2008 Sep 16
2
Hosmer- Lemeshow test
Dear R - help,
I am working on the Credit scorecard model. I am using the Logistic regression to arrive at the regression coefficients model.
I want to use the Hosmer - Lemeshow test .
In order to understand the use of R - language, I had referred the following URL
http://www.stat.sc.edu/~hitchcock/diseaseoutbreakRexample704.txt
The related data 'diseaseoutbreak' is available
2011 May 08
1
Hosmer-Lemeshow 'goodness of fit'
I'm trying to do a Hosmer-Lemeshow 'goodness of fit' test on my logistic
regression model.
I found some code here:
http://sas-and-r.blogspot.com/2010/09/example-87-hosmer-and-lemeshow-goodness.html
The R code is above is a little complicated for me but I'm having trouble
with my answer:
Hosmer-Lemeshow: p=0.6163585
le Cessie and Houwelingen test (Design library): p=0.2843620
2012 Nov 16
2
R-Square in WLS
Hi,
I am fitting a weighted least square regression and trying to compute
SSE,SST and SSReg but I am not getting SST = SSReg + SSE and I dont know
what I am coding wrong. Can you help please?
xnam <-colnames(X) # colnames Design Matrix
fmla1 <- as.formula(paste("Y ~",paste(xnam, collapse=
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
2004 Mar 05
4
Probit predictions outside (0,1) interval
Hi!
I was trying to implement a probit model on a dichotomous outcome variable and found that the predictions were outside the (0,1) interval that one should get. I later tried it with some simulated data with a similar result.
Here is a toy program I wrote and I cant figure why I should be getting such odd predictions.
x1<-rnorm(1000)
x2<-rnorm(1000)
x3<-rnorm(1000)
2006 Apr 01
1
Nested error structure in nonlinear model
I am trying to fit a nonlinear regression model to data. There are
several predictor variables and 8 parameters. I will write the model as
Y ~ Yhat(theta1,...,theta8)
OK, I can do this using nls() - but "only just" as there are not as many
observations as might be desired.
Now the problem is that we have a factor "Site" and I want to include a
corresponding error
2013 Apr 23
1
Hosmer Lemeshow test
Hi to everybody. I use the following routine (i found it in the internet)
to compute the Hosmer-Lemeshow test in the framework of logistic regression.
hosmerlemeshow = function(obj, g=10) {
# first, check to see if we fed in the right kind of object
stopifnot(family(obj)$family=="binomial" && family(obj)$link=="logit")
y = obj$model[[1]]
# the double bracket
2008 Nov 07
1
two kind of Hosmer and Lemeshow’s test
I know that there are two method to apply the Hosmer and Lemeshow?s. One of
them is calculated based on the fixed and pre-determined cut-off points of
the estimated probability of success. One of them is calculated based on
the percentiles of estimated probabilities.
In the previous post,i find that the Hosmer and Lemeshow?s test how to use
in R.
hosmerlem <-
function (y, yhat, g = 10)
{
2010 Apr 25
1
function pointer question
Hello,
I have the following function that receives a "function pointer" formal parameter name "fnc":
loocv <- function(data, fnc) {
n <- length(data.x)
score <- 0
for (i in 1:n) {
x_i <- data.x[-i]
y_i <- data.y[-i]
yhat <- fnc(x=x_i,y=y_i)
score <- score + (y_i - yhat)^2
}
score <- score/n
2005 Mar 09
1
Trouble with mixreg
Dear All
I am trying to estimate a mixture of regression and get the
following error using the mixreg package:
Error in y - yhat : non-conformable arrays
The instruction I used were:
x <- as.matrix(LRHUN)
y <- as.matrix(LRINTER)
TS <- list(list(beta=c(3.0,1.0),sigsq=1,lambda=0.4),
list(beta=c(0.0,1.0),sigsq=1,lambda=0.6))
prova <- mixreg(x,y, ncomp=2, theta.start=TS)
2013 Apr 14
5
Logistic regression
I have a data set to be analyzed using to binary logistic regression. The
data set is iin grouped form. My question is: how I can compute
Hosmer-Lemeshow test and measures like sensitivity and specificity? Any
suggestion will be greatly appreciated.
Thank you
Endy
[[alternative HTML version deleted]]
2009 Apr 07
1
get optim results into a model object
Hello all, I have an optimization routine that is giving me good results,
but the results are not in the nice "model" format like "lm". How can I get
optim results into a model so that I can use the clever 'fitted',
'residuals', and 'summary' functions?
Using optim is the only way that I was able to make a model that
1) sums the betas to 1,
2)
2012 Jul 18
1
Regression Identity
Hi,
I see a lot of folks verify the regression identity SST = SSE + SSR
numerically, but I cannot seem to find a proof. I wonder if any folks on
this list could guide me to a mathematical proof of this fact.
Thanks.
David.
--
View this message in context: http://r.789695.n4.nabble.com/Regression-Identity-tp4636829.html
Sent from the R help mailing list archive at Nabble.com.
2010 Jul 07
1
Different goodness of fit tests leads to contradictory conclusions
I am trying to test goodness of fit for my legalistic regression using several options as shown below. Hosmer-Lemeshow test (whose function I borrowed from a previous post), Hosmer–le Cessie omnibus lack of fit test (also borrowed from a previous post), Pearson chi-square test, and deviance test. All the tests, except the deviance tests, produced p-values well above 0.05. Would anyone please
2010 Jul 09
1
Appropriate tests for logistic regression with a continuous predictor variable and Bernoulli response variable
I have a data with binary response variable, repcnd (pregnant or not) and one predictor continuous variable, svl (body size) as shown below. I did Hosmer-Lemeshow test as a goodness of fit (as suggested by a kind “R-helper” previously). To test whether the predictor (svl, or body size) has significant effect on predicting whether or not a female snake is pregnant, I used the differences between
2005 Oct 04
1
Rcmdr and scatter3d
Hi folks,
I'd like to use scatter3d (which is in R commander) to plot more than one
dataset in the same graph, each dataset with a different color. The kind
of stuff you would do with "holdon" in Matlab.
I read a recent message that was posted to this list with a similar
problem, but I couldn't understand the reply. Could someone give me one
example? How do you plot subgroups