Displaying 20 results from an estimated 800 matches similar to: "Issues when using interaction term with a lagged variable"
2006 Jun 06
1
Problems using quadprog for solving quadratic programming problem
Hi,
I'm using the package quadprog to solve the following quadratic programming problem.
I want to minimize the function
(b_1-b_2)^2+(b_3-b_4)^2
by the following constraints b_i, i=1,...,4:
b_1+b_3=1
b_2+b_4=1
0.1<=b_1<=0.2
0.2<=b_2<=0.4
0.8<=b_3<=0.9
0.6<=b_4<=0.8
In my opinion the solution should be b_1=b_2=0.2 und b_3=b_4=0.8.
Unfortunately R doesn't find
2010 Jan 19
1
change codes into loops
Hi,
See example.
for (i in 1:2) {
for (j in 1:3) {
b_1[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[1]
b_2[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[2]
b_3[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[3]
}
}
The inner codes is really repeated, so i want to change the inner codes
into loops. Take nn is from 1 to 3,
something like,
for (nn in 1:3) {
2011 Dec 05
1
Summary coefficients give NA values because of singularities
Hello,
I have a data set which I am using to find a model with the most significant
parameters included and most importantly, the p-values. The full model is
of the form:
sad[,1]~b_1 sad[,2]+b_2 sad[,3]+b_3 sad[,4]+b_4 sad[,5]+b_5 sad[,6]+b_6
sad[,7]+b_7 sad[,8]+b_8 sad[,9]+b_9 sad[,10],
where the 9 variables on the right hand side are all indicator variables.
The thing I don't understand
2012 May 09
1
reception of (Vegan) envfit analysis by manuscript reviewers
I'm getting lots of grief from reviewers about figures generated with
the envfit function in the Vegan package. Has anyone else struggled to
effectively explain this analysis? If so, can you share any helpful
tips?
The most recent comment I've gotten back: "What this shows is which
NMDS axis separates the communities, not the relationship between the
edaphic factor and the
2012 Feb 29
2
How to replace the values in a column
Dear All,
I've been searching relevant topics about replacing values, none seemed to
be applicable to me...
I have a file with many many varieties, and want to replace some of them
into different names.
I tried various of ways, still don't know how to do that most efficiently..
Here is part of the example data:
Gen Rep
A_1 1
A_1 2
A_2 1
A_2 2
B_1 1
B_1
2011 Sep 02
1
Using capture.output within a function
Dear R-users
I'm running a maximum likelihood procedure using the spg package. I'd like
to save some output produced in each iteration to a file, but if I put the
capture.output() within the function I get the following message; Error in
spg(par = startval, fn = loglik, gr = NULL, method = 3, lower = lo, :
Failure in initial function evaluation!Error in -fn(par, ...) : invalid
argument
2009 Jun 11
2
Optimization Question
Hi All
Apologies if this is not the correct list for this question.
The Rglpk package offers the following example in its documentation
library(Rglpk)
## Simple mixed integer linear program.
## maximize: 3 x_1 + 1 x_2 + 3 x_3
## subject to: -1 x_1 + 2 x_2 + x_3 <= 4
## 4 x_2 - 3 x_3 <= 2
## x_1 - 3 x_2 + 2 x_3 <= 3
## x_1, x_3 are non-negative integers
## x_2 is a non-negative real
2006 Jun 08
1
panel.abline and xyplot
Dear All,
I am wondering on how to use the abline.xyplot with xyplot such that I will have different vertical lines for each panel. More sepcifically, suppose that the xyplot generates 4 panels defined by the combination of two binary variables: X_1 and X_2. i.e.
xyplot(Y ~ Z | X_1*X_2, data = df)
I want something like:
abline(v = 5) if X_1=0 and X_2 = 0
abline(v =
2008 Aug 04
2
Multivariate Regression with Weights
Hi all,
I'd like to fit a multivariate regression with the variance of the error term porportional to the predictors, like the WLS in the univariate case.
y_1~x_1+x_2
y_2~x_1+x_2
var(y_1)=x_1*sigma_1^2
var(y_2)=x_2*sigma_2^2
cov(y_1,y_2)=sqrt(x_1*x_2)*sigma_12^2
How can I specify this in R? Is there a corresponding function to the univariate specification lm(y~x,weights=x)??
2003 Feb 19
4
fitting a curve according to a custom loss function
Dear R-Users,
I need to find a smooth function f() and coefficients a_i that give the best
fit to
y ~ a_0 + a_1*f(x_1) + a_2*f(x_2)
Note that it is the same non-linear transformation f() that is applied to
both x_1 and x_2.
So my first question is how can I do it in R?
A more general question is this: suppose I have a utility function U(a_i,
f()), where f() is say a spline. Is there a general
2009 Dec 04
2
Solve linear program without objective function
Dear R-users,
i try to solve to following linear programm in R
0 * x_1 + 2/3 * x_2 + 1/3 * x_3 + 1/3 * x_4 = 0.3
x_1 + x_2 + x_3 + x_4 = 1
x_1, x_2, x_3, x_4 > 0,
x_1, x_2, x_3, x_4 < 1
as you can see i have no objective function here besides that i use the
following code.
library(lpSolve)
f.obj<-c(1,1,1,1)
f.con<-matrix(c(0,2/3,1/3,1/3,
1,1,1,1,
2007 Mar 29
3
Tail area of sum of Chi-square variables
Dear R experts,
I was wondering if there are any R functions that give the tail area
of a sum of chisquare distributions of the type:
a_1 X_1 + a_2 X_2
where a_1 and a_2 are constants and X_1 and X_2 are independent chi-square variables with different degrees of freedom.
Thanks,
Klaus
--
"Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ...
2004 May 21
2
Help with Plotting Function
Dear List:
I cannot seem to find a way to plot my data correctly. I have a small data frame with 6 total variables (x_1 ... x_6).
I am trying to plot x_1 against x_2 and x_3.
I have tried
plot(x_2, x_1) #obviously works fine
plot(x_3, x_1, add=TRUE) # Does not work. I keep getting error messages.
I would also like to add ablines to this plot.
I have experimented with a number of other
2009 Oct 01
1
Help for 3D Plotting Data on 'Irregular' Grid
Dear All,
Here is what I am trying to achieve: I would like to plot some data in 3D.
Usually, one has a matrix of the kind
y_1(x_1) , y_1(x_2).....y_1(x_i)
y_2(x_1) , y_2(x_2).....y_2(x_i)
...........................................
y_n(x_1) , y_n(x_2)......y_n(x_i)
where e.g. y_2(x_1) is the value of y at time 2 at point x_1 (see that
the grid in x is the same for the y values at all times).
2005 Oct 13
3
Do Users of Nonlinear Mixed Effects Models Know Whether Their Software Really Works?
Do Users of Nonlinear Mixed Effects Models Know
Whether Their Software Really Works?
Lesaffre et. al. (Appl. Statist. (2001) 50, Part3, pp 325-335)
analyzed
some simple clinical trials data using a logistic random effects
model. Several packages and methods MIXOR, SAS NLMIXED were employed.
They reported obtaining very different parameter estimates and
P
2012 Sep 20
1
Gummy Variable : Doubt
Hi,
I have a system in which I analyze 2 subjects and 1 variable, so I have
2 models as follow:
y ~ x_1[, 1] + x_2[, 1] + x_1[, 2] + x_2[, 2]
Where
x_1[, i] = cos(2 * pi * t / T_i)
x_2[, i] = sin(2 * pi * t / T_i)
i = 1, 2
Data have two columns: t and y.
As you can see, I have a multiple components model, with rithm and
without trends, and I have a fundamental
2000 Oct 03
5
Where is gam?
I noticed that there is no generalised additive model functions in R
(1.1.1) ... is there a package that implements them?
Thanks
Prasad
*****************************************************************
Mr. Anantha Prasad, Ecologist/GIS Specialist
USDA Forest Service, 359 Main Rd.
Delaware OHIO 43015 USA
Ph: 740-368-0103 Email: aprasad at fs.fed.us
Web:
2012 Sep 05
2
Improvement of Regression Model
Hello folks,
I am on learning phase of R. I have developed Regression Model over six
predictor variables. while development, i found my all data are not very
linear. So, may because of this the prediction of my model is not exact.
Here is the summary of model :
Call:
lm(formula = y ~ x_1 + x_2 + x_3 + x_4 + x_5 + x_6)
Residuals:
Min 1Q Median 3Q Max
-125.302
2019 May 16
5
nrow(rbind(character(), character())) returns 2 (as documented but very unintuitive, IMHO)
Hi all,
Apologies if this has been asked before (a quick google didn't find it for
me),and I know this is a case of behaving as documented but its so
unintuitive (to me at least) that I figured I'd bring it up here anyway. I
figure its probably going to not be changed, but I'm happy to submit a
patch if this is something R-core feels can/should change.
So I recently got bitten by
2011 May 22
2
Finding solution set of system of linear equations.
I have a simple system of linear equations to solve for X, aX=b:
> a
[,1] [,2] [,3] [,4]
[1,] 1 2 1 1
[2,] 3 0 0 4
[3,] 1 -4 -2 -2
[4,] 0 0 0 0
> b
[,1]
[1,] 0
[2,] 2
[3,] 2
[4,] 0
(This is ex Ch1, 2.2 of Artin, Algebra).
So, 3 eqs in 4 unknowns. One can easily use row-reductions to find a
homogeneous solution(b=0) of:
X_1