Displaying 20 results from an estimated 1000 matches similar to: "Power model in R"
2006 Jan 25
2
Question about fitting power
Hi R users
I'm trying to fit a model y=ax^b.
I know if I made ln(y)=ln(a)+bln(x) this is a linear regression.
But I obtain differente results with nls() and lm()
My commands are: nls(CV ~a*Est^b, data=limiares, start =list(a=100,b=0),
trace = TRUE) for nonlinear regression
and : lm(ln_CV~ln_Est, data=limiares) for linear
regression
Nonlinear
2007 May 02
3
ED50 from logistic model with interactions
Hi,
I was wondering if someone could please help me. I am doing a logistic
regression to compare size at maturity between 3 seasons. My model is:
fit <- glm(Mature ~ Season * Size - 1, family = binomial, data=dat)
where Mature is a binary response, 0 for immature, 1 for mature. There
are 3 Seasons.
The Season * Size interaction is significant. I would like to compare the
size at 50%
2009 May 09
2
Sweave \Sexpr{} advice please
Dear List,
First off, my deepest gratitude to the Sweave developers: this tool has
improved my quality greatly.
A question in my work I use \Sexpr{} statements scalar values and the xtable
package for all manner of tables. What I'd like to do is to use a vector
inline, rather than a whole separate table. Something like:
%%%%%%%%%%%%%%%% begin code
% Latex junk
% Sweave block:
2007 Feb 06
3
How-To construct a cov list to use a covariance matrix in factanal?
Hi,
I have a set of covariance matrices but not the original data. I want to carry out some exploratory factor analysis. So, I am trying to construct a covariance matrix list as the input for factanal. I can construct a list which includes the cov, the centers, and the n.obs. But it doesn't work. I get an error that says "Error in sqrt(diag(cv)) : Non-numeric argument to mathematical
2008 Oct 09
2
vectorization instead of using loop
Dear all,
I've sent this question 2 days ago and got response from Sarah. Thanks for
that. But unfortunately, it did not really solve our problem. The main issue
is that we want to use our own (manipulated) covariance matrix in the
calculation of the mahalanobis distance. Does anyone know how to vectorize
the below code instead of using a loop (which slows it down)?
I'd really appreciate
2011 Oct 18
1
Repeat a loop until...
Dear all,
I know there have been various questions posted over the years about loops but I'm afraid that I'm still stuck. I am using Windows XP and R 2.9.2.
I am generating some data using the multivariate normal distribution (within the 'mnormt' package). [The numerical values of sanad and covmat are not important.]
> datamat <-
2012 Sep 17
2
Constraint Optimization with constrOptim
Hi,
I am having trouble using constrOptim. My target is to do a portfolio optimization and there some constraints have to be fulfilled.
1) The weight of each share of the portfolio has to be greater than 0
2) The sum of these weights has to be 1
I am able to fulfill either the first or the second constraint but not both.
One simple way would be to fulfill the first constraint by using optim as
2004 Nov 16
5
Difference between two correlation matrices
Hi
Now a more theoretical question. I have two correlation matrices - one
of a set of variables under a particular condition, the other of the
same set of variables under a different condition. Is there a
statistical test I can use to see if these correlation matrices are
"different"?
Thanks
Mick
1997 Apr 30
1
R-beta: ls.print
ls.print produces error that I don't seem to be able to trace.
Output of the commands as follows: (hyeung is a 24x2 matrix of data)
-------------------------------------------------
> summary(hyeung)
x.1 x.2
Min. : 28.0 Min. : 10.0
1st Qu.: 72.0 1st Qu.: 87.5
Median : 86.5 Median : 92.5
Mean : 81.0 Mean : 82.5
3rd Qu.: 97.0 3rd Qu.:100.0
Max.
1997 Apr 30
1
R-beta: ls.print
ls.print produces error that I don't seem to be able to trace.
Output of the commands as follows: (hyeung is a 24x2 matrix of data)
-------------------------------------------------
> summary(hyeung)
x.1 x.2
Min. : 28.0 Min. : 10.0
1st Qu.: 72.0 1st Qu.: 87.5
Median : 86.5 Median : 92.5
Mean : 81.0 Mean : 82.5
3rd Qu.: 97.0 3rd Qu.:100.0
Max.
2003 Aug 08
1
covmat argument in princomp() (PR#3682)
R version: 1.7.1
OS: Red Hat Linux 7.2
When "covmat" is supplied in princomp(), the output value "center" is all
NA's, even though the input matrix was indeed centered. I haven't read
anything about this in the help file for princomp(). See code below for an
example: pc2$center is all NA's.
Jerome Asselin
x <- rnorm(6)
y <- rnorm(6)
X <- cbind(x,y)
2009 Jan 05
2
Sweave data-figure coupling
Hi,
With the following Sweave minimal file:
---<--------------------cut here---------------start------------------->---
\documentclass{article}
\usepackage{Sweave}
\begin{document}
<<binom-sim>>=
thetas <- seq(0, 1, by=0.001)
prior <- rep(1, length(thetas)) / length(thetas)
lik <- dbinom(1, 1, thetas)
lik.p <- prior * lik
post <- lik.p / sum(lik.p)
2002 Aug 29
2
Factor Analysis in MASS4
Hi,
I had a look at the MASS4 scripts in the MASS package, in Ch 11.3 Factor
Analysis, there is a section of codes like:
data(ability.cov)
ability.FA <- factanal(covmat = ability.cov, factors = 1)
ability.FA
(ability.FA <- update(ability.FA, factors = 2))
#summary(ability.FA)
round(loadings(ability.FA) %*% t(loadings(ability.FA)) +
diag(ability.FA$uniq), 3)
2012 May 28
3
Factanal fits
Greetings, all:
I am using factanal in R.
When I enter a matrix or a formula, the print method winds up with something like this:
Test of the hypothesis that 6 factors are sufficient.
The chi square statistic is 28.1 on 22 degrees of freedom.
The p-value is 0.172
But when I enter a covmat, the print method winds up with something like this:
The degrees of freedom for the model is 22 and the
2008 Sep 09
1
Addendum to wishlist bug report #10931 (factanal) (PR#12754)
--=-hiYzUeWcRJ/+kx41aPIZ
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
Hi,
on March 10 I filed a wishlist bug report asking for the inclusion of
some changes to factanal() and the associated print method. The changes
were originally proposed by John Fox in 2005; they make print.factanal()
display factor correlations if factanal() is called with rotation =
2009 Jan 30
1
Factor Analysis-factanal function
Dear friends,
I'm using R to produce the following Factor Analysis:
> matriz.cor<-hetcor(matrix(as.factor(data), ncol=variables,
byrow=T))$correlations
> factanal(x=data, factors=2, covmat=matriz.cor, scores='regression')
Then the screen output shows the following message:
Error en factanal(x = data, factors = 2, covmat = matrix, :
requested scores without
2011 Jun 11
2
Factor Analysis/Inputting Correlation Matrix
Can someone please direct me to how to run a factor analysis in R by first inputting a correlation matrix? Does the function "factanal" allow one to read a correlation matrix instead of data vectors?
Thanks,
Matt.
[[alternative HTML version deleted]]
2011 Mar 19
2
problem running a function
Dear people,
I'm trying to do some analysis of a data using the models by Royle & Donazio
in their fantastic book, particular the following function:
http://www.mbr-pwrc.usgs.gov/pubanalysis/roylebook/panel4pt1.fn
that applied to my data and in the console is as follows:
> `desman.y` <- structure(c(3L,4L,3L,2L,1L), .Names = c("1", "2", "3",
2007 Oct 24
1
vectorized mle / optim
Hi the list,
I would need some advice on something that looks like a FAQ: the
possibility of providing vectors to optim() function.
Here is a stupid and short example summarizing the problem:
-------------------------------- example 1 ------------ 8<
----------------------
library(stats4)
data <- rnorm(100,0,1)
lik1 <- function(m, v, data) {
N <- length(data)
lik.mean <-
2007 May 19
2
What's wrong with my code ?
I try to code the ULS factor analysis descrbied in
ftp://ftp.spss.com/pub/spss/statistics/spss/algorithms/ factor.pdf
# see PP5-6
factanal.fit.uls <- function(cmat, factors, start=NULL, lower = 0.005,
control = NULL, ...)
{
FAfn <- function(Psi, S, q)
{
Sstar <- S - diag(Psi)
E <- eigen(Sstar, symmetric = TRUE, only.values = TRUE)
e <- E$values[-(1:q)]
e <-