Displaying 20 results from an estimated 3000 matches similar to: "Regression coefficient constraints"
2006 Sep 18
1
non linear modelling with nls: starting values
Hi,
I'm trying to fit the following model to data using 'nls':
y = alpha_1 * beta_1 * exp(-beta_1 * x) +
alpha_2 * beta_2 * exp(-beta_2 * x)
and the call I've been using is:
nls(y ~ alpha_1 * beta_1 * exp(-beta_1 * x) +
alpha_2 * beta_2 * exp(-beta_2 * x),
start=list(alpha_1=4, alpha_2=2, beta_1=3.5, beta_2=2.5),
trace=TRUE, control=nls.control(maxiter =
2010 Sep 11
5
for loop
Hello,
I have a simple question: I want to list numbers 1:k, but if k <1, I hope nothing listed.
how should we do?
k=2
for (i in 1:k) print(i)
[1] 1 # <-correct
[1] 2
k=0
for (i in 1:k) print(i)
[1] 1 #<---- wrong
[1] 0
thanks
jian
[[alternative HTML version deleted]]
2007 Jun 13
1
specify constraints in maximum likelihood
Hi,I know only mle function but it seems that in mle one can only specify the bound of the unknowns forming the likelihood function. But I would like to specify something like, a = 2b or a <= 2b where 'a' and 'b' could be my parameters in the likelihood function. Any help would be really appreciated. Thank you!- adschai
[[alternative HTML version deleted]]
2010 Nov 09
3
Row-wise recurive function call
Dear Group,
I have a following dataset:
> a
A B C D
1 22 3 31 40
2 26 31 36 32
3 3 7 49 16
4 24 40 27 26
5 20 45 47 0
6 34 43 11 18
7 48 48 24 2
8 3 16 39 48
9 20 49 7 21
10 17 36 47 10
> dput(a)
structure(list(A = c(22L, 26L, 3L, 24L, 20L, 34L, 48L, 3L, 20L,
17L), B = c(3L, 31L, 7L, 40L, 45L, 43L, 48L, 16L, 49L, 36L),
C = c(31L, 36L, 49L, 27L, 47L, 11L, 24L,
2012 Apr 20
3
Matrix multiplication by multple constants
Dear R helpers
Suppose
x <- c(1:3)
y <- matrix(1:12, ncol = 3, nrow = 4)
> y
[,1] [,2] [,3]
[1,] 1 5 9
[2,] 2 6 10
[3,] 3 7 11
[4,] 4 8 12
I wish to multiply 1st column of y by first element of x i.e. 1, 2nd column of y by 2nd element of x i.e. 2 an so on. Thus the resultant matrix should be like
> z
[,1] [,2] [,3]
[1,] 1
2006 Nov 01
1
coefficient constraints
Hi,
Thank you for your help. I'm trying to constrain the coefficients on a
linear regression model, <-lm(...), to all equal one, except for the
intercept. I've searched help(glm), help(model.fit), etc. but I can not
find where to add the constraint. Your help would be greatly appreciated.
Thanks.
[[alternative HTML version deleted]]
2012 Nov 01
3
convert list without same component length to matrix
Hi,
I have this lame question. I want to convert a list (each with varies in
length) to matrix with same row length by eliminating vectors outside the
needed range.
For example:
l<-list(NULL)
l[[1]]=1,2,3.7
l[[2]]=3,4,5,6,3
l[[3]]=4,2,5,7
l[[4]]=2,4,6,3,2
l[[5]]=3,5,7,2
#so say I want to only have 4 rows and 5 column in my matrix (or
data.frame) and eliminating the 5th index value in l[[2]]
2011 Aug 23
4
Correlation discrepancy
Dear R list, I have one very elementary question regrading correlation between two variables.
x = c(44,46,46,47,45,43,45,44)
y = c(44,43,41,41,46,48,44,43)
> cov(x, y)
[1] -2.428571
However, if I try to calculate the covariance using the formula as
covariance = sum((x-mean(x))*(y-mean(y)))/8 # no of of paired obs. = 8
or
covariance = sum(x*y)/8-(mean(x)*mean(y))
gives
2011 Mar 13
1
using pre-calculated coefficients and LP in coxph()?
I need to force a coxph() function in R to use a pre-calculated set of beta
coefficients of a gene signature consisting of xx genes and the gene
expression is also provided of those xx genes.
If I try to use "coxph()" function in R using just the gene expression data
alone, the beta coefficients and coxph$linear.predictors will change and I
need to use the pre-calcuated linear predictor
2011 Aug 19
3
Calculating p-value for 1-tailed test in a linear model
Hello,
I'm having trouble figuring out how to calculate a p-value for a 1-tailed
test of beta_1 in a linear model fit using command lm. My model has only 1
continuous, predictor variable. I want to test the null hypothesis beta_1
is >= 0. I can calculate the p-value for a 2-tailed test using the code
"2*pt(-abs(t-value), df=degrees.freedom)", where t-value and degrees.freedom
2010 Nov 07
3
regular exprs
Dear All,
I would appreciate any help with the following: given the vector 'x'
x <- c("Ass1", "Ass.s1", "Ass2", "Ass.s2")
I would like to pick up the positions where the character string
contains "Ass" but does not contain "Ass.s", so for 'x' that would be
positions 1 and 3.
I guess this could be programmed around
2010 Oct 15
4
split data with missing data condition
Dear all
I have data like this:
x y
[1,] 59.74889 3.1317081
[2,] 38.77629 1.7102589
[3,] NA 2.2312962
[4,] 32.35268 1.3889621
[5,] 74.01394 1.5361227
[6,] 34.82584 1.1665412
[7,] 42.72262 2.7870875
[8,] 70.54999 3.3917257
[9,] 59.37573 2.6763249
[10,] 68.87422 1.9697770
[11,] 19.00898 2.0584415
[12,] 60.27915 2.5365194
[13,] 50.76850
2009 Feb 07
1
paraPen in gam [mgcv 1.4-1.1] and centering constraints
Dear Mr. Simon Wood, dear list members,
I am trying to fit a similar model with gam from mgcv compared to what I
did with BayesX, and have discovered the relatively new possibility of
incorporating user-defined matrices for quadratic penalties on
parametric terms using the "paraPen" argument. This was really a very
good idea!
However, I would like to constraint the coefficients
2006 Oct 31
2
Put a normal curve on plot
I would like to be able to place a normal distribution surrounding the
predicted values at various places on a plot. Below is some toy code
that creates a scatterplot and plots a regression line through the data.
library(MASS)
mu <- c(0,1)
Sigma <- matrix(c(1,.8,.8,1), ncol=2)
set.seed(123)
x <- mvrnorm(50,mu,Sigma)
plot(x)
abline(lm(x[,2] ~ x[,1]))
Say I want to add a normal
2013 Oct 20
5
nlminb() - how do I constrain the parameter vector properly?
Greets,
I'm trying to use nlminb() to estimate the parameters of a bivariate normal sample and during one of the iterations it passes a parameter vector to the likelihood function resulting in an invalid covariance matrix that causes dmvnorm() to throw an error. Thus, it seems I need to somehow communicate to nlminb() that the final three parameters in my parameter vector are used to
2005 Dec 01
2
Minimizing a Function with three Parameters
Hi,
I'm trying to get maximum likelihood estimates of \alpha, \beta_0 and
\beta_1, this can be achieved by solving the following three equations:
n / \alpha + \sum\limits_{i=1}^{n} ln(\psihat(i)) -
\sum\limits_{i=1}^{n} ( ln(x_i + \psihat(i)) ) = 0
\alpha \sum\limits_{i=1}^{n} 1/(psihat(i)) - (\alpha+1)
\sum\limits_{i=1}^{n} ( 1 / (x_i + \psihat(i)) ) = 0
\alpha \sum\limits_{i=1}^{n} (
2009 Jun 16
1
turning off escape sequences for a string
Hello,
I would like to create a matrix with one of the columns named
$\delta$. I have also created columns $\beta_1$ , $\beta_2$, etc.
However, it seems like \d is an escape sequence which gets
automatically removed. (Using these names such that they work right in
xtable -> latex)
colnames(simpleReg.mat) <- c("$\beta_1$","$SE(\beta_1)$", "$\beta_2$",
2006 Sep 27
2
Constrained OLS regression
Hello R helpers,
I am trying to do a linear OLS regression of y on two variables x1 and
x2. I want to constrain the coefficients of x1 and x2 to sum up to 1.
and therefore run a constrained OLS. Can anybody help with this? (I have
seen some answers to similar questions but it was not clear to me what I
need to do) - I have tried the lm function with offset but I must not
have used it properly.
2011 May 02
2
vector decreasing by a factor
Hi,
I'm quite new to R so this question will sound quite fundamental. I need to create a vector of length 160. The first element should be (1+r)^159 and each element thereafter should decrease by a factor of (1+r) until the 160th element that should be 1. Is there a function similar to seq() but increasing or decreasing by factors? I need to do this in one step i.e, not using loops. Any help
2010 Sep 10
2
survfit question
Hi,
I am attempting to graph a Kaplan Meier estimate for some claims using the survfit function. However, I was wondering if it is possible to plot a cdf of the kaplan meier rather than the survival function. Here is some of my code:
library(survival)
Surv(claimj,censorj==0)
survfit(Surv(claimj,censorj==0)~1)
surv.all<-survfit(Surv(claimj,censorj==0)~1)
summary(surv.all)
plot(surv.all)