Displaying 20 results from an estimated 2000 matches similar to: "sas retain statement in R or fitting differene equations in NLS"
2012 Mar 06
0
Fitting difference models in R (nls, nlme)
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 which
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
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
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
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
2010 Feb 13
2
lm function in R
Hello,
I am trying to learn how to perform Multiple Regression Analysis in R. I
decided to take a simple example given in this PDF:
http://www.utdallas.edu/~herve/abdi-prc-pretty.pdf
I created a small CSV called, students.csv that contains the following data:
s1 14 4 1
s2 23 4 2
s3 30 7 2
s4 50 7 4
s5 39 10 3
s6 67 10 6
Col headers: Student id, Memory span(Y), age(X1), speech rate(X2)
Now
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
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
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=
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
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)
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
2012 Jul 17
1
Threshold Quantile Regression code CRASHES in R
I am working on a two stage threshold quantile regression model in R, and my aim is to estimate the threshold of the reduced-form equation (call it rhohat), and the threshold of the structural equation (call it qhat), in two stages. On the first stage, i estimate rhohat by quantile regression and obtain the fitted values. I use these fitted values to estimate qhat on the second stage. The code is
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
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)
2009 Oct 26
1
Cbind() on the right-side of a formula in xYplot()
Hi,
Using the latest rms package I am able to make nice plots of model predictions
+/- desired confidence intervals like this:
# need this
library(rms)
# setup data
d <- data.frame(x=rnorm(100), y=rnorm(100))
dd <- datadist(d)
options(datadist='dd')
# fit model
l <- ols(y ~ rcs(x), data=d)
# predict along original limits of data
l.pred <- Predict(l)
# plot of fit and
2005 Jul 07
1
spurious regression in R
Hi:
I am trying to do a spurious regression in R but I
can not find the function. Anybody used it before? The
problem I have is try to do a regression with several
time series. An alternative is to use the GLS function
to fit the linear regression with the correlation
structure AR(3) for the response (or residual). I hope
the residuals after the GLS regression will be
independent judged by