Displaying 20 results from an estimated 100 matches similar to: "trouble using optim for maximalisation of 2-parameter function"
2011 Jul 01
2
Help fix last line of my optimization code
Hi
I need help figure out how to fix my code.
When I call into R
>optimize(llik,init.params=F)
I get this error message
####Error in optimize(llik, init.params = F) : element 1 is empty;
the part of the args list of 'min' being evaluated was:
(interval)####
My data and my code looks like below.
R_j R_m
0.002 0.026567296
0.01 0.003194435
. .
. .
. .
. .
0.0006
2007 Apr 18
3
Problems in programming a simple likelihood
As part of carrying out a complicated maximum likelihood estimation, I
am trying to learn to program likelihoods in R. I started with a simple
probit model but am unable to get the code to work. Any help or
suggestions are most welcome. I give my code below:
************************************
mlogl <- function(mu, y, X) {
n <- nrow(X)
zeta <- X%*%mu
llik <- 0
for (i in 1:n) {
if
2011 Jul 03
3
Hint improve my code
Hi
I have developed the code below. I am worried that the parameters I want to
be estimated are "not being found" when I ran my code. Is there a way I can
code them so that R recognize that they should be estimated.
This is the error I am getting.
> out1=optim(llik,par=start.par)
Error in pnorm(au_j, mean = b_j * R_m, sd = sigma_j) :
object 'au_j' not found
#Yet
2011 Jul 04
3
loop in optim
Hi
May you help me correct my loop function.
I want optim to estimates al_j; au_j; sigma_j; b_j by looking at 0 to 20,
21 to 40, 41 to 60 data points.
The final result should have 4 columns of each of the estimates AND 4 rows
of each of 0 to 20, 21 to 40, 41 to 60.
###MY code is
n=20
runs=4
out=matrix(0,nrow=runs)
llik = function(x)
{
al_j=x[1]; au_j=x[2]; sigma_j=x[3]; b_j=x[4]
2011 Jul 23
1
Extend my code to run several data at once.
Hi
I have a code that calculate maximisation using optimx and it is working
just fine. I want to extend the code to run several colomns of R_j where j
runs from 1 to 200. If I am to run the code in its current state, it means I
will have to run it 200 times manually. May you help me adjust it to
accomodate several rows of R_j and print the 200 results.
***Please do not get intimidated by the
2011 Jun 14
1
Using MLE Method to Estimate Regression Coefficients
Good Afternoon,
I am relatively new to R and have been trying to figure out how to estimate regression coefficients using the MLE method. Some background: I am trying to examine scenarios in which certain estimators might be preferred to others, starting with MLE. I understand that MLE will (should) produce the same results as Ordinary Least Squares if the assumption of normality holds. That
2003 Sep 08
1
Probit and optim in R
I have had some weird results using the optim() function. I wrote a
probit likelihood and wanted to run it with optim() with simulated
data. I did not include a gradient at first and found that optim()
would not even iterate using BFGS and would only occasionally work
using SANN. I programmed in the gradient and it iterates fine but the
estimates it returns are wrong. The simulated data work
2011 Jul 06
1
Group Data indexed by n Variables
Hello,
the more general thing I'd like to learn here is how to compute Function of
Data on the basis of grouping determiend by n variables.
In terms of the reason why I am interested in this, I need to compute the
average of my data based on the value of the month and day across years. I
have come up withy the code below which, as far as I can see, does what I
need but getting either a more
2005 Nov 25
3
obtaining a ROC curve
Hello,
I have a classification tree. I want to obtain a ROC curve for this test. What is the easiest way to obtain one?
-Anjali
---------------------------------
[[alternative HTML version deleted]]
2005 Oct 07
2
AIC in lmer
Hello all,
Is AIC calculated incorrectly in lmer? It appears as though it uses
AIC = -2*logLik - 2*#parms, instead of -2*LogLik + 2*#parms? Below is
output from one of many models I have tried:
Generalized linear mixed model fit using PQL
Formula: cswa ~ pcov.ess1k + (1 | year)
Data: ptct50.5
Family: poisson(log link)
AIC BIC logLik deviance
224.8466 219.19 -114.4233 228.8466
2012 Jun 12
3
String Manipulation in R
Hi ,
Is there any inbuilt functions to check whether a substring is present in a
string and give the result as boolean
Thanks
--
View this message in context: http://r.789695.n4.nabble.com/String-Manipulation-in-R-tp4633104.html
Sent from the R help mailing list archive at Nabble.com.
2004 Jun 17
0
beta regression in R
Hello,
I'm using optim to program a set of mle regression procedures for non-normal
disturbances. This is for teaching and expository purposes only. I've
successfully programmed the normal, generalized gamma, gamma, weibull,
exponential, and lognormal regression functions. And optim returns
reasonable answers for all of these compared with the identical optimization
problems in STATA and
2006 May 17
1
Column notation
Hello,
I would like to run a correlation on values in a table that
has 4 rows and 136 columns. However, I am only interested in
correlating the values in alternating blocks of 15 columns.
For example, I would like to correlate the values in row 1,
columns 2-16:31-46:61-76:91-106 with values in row 2, columns
2-16:31-46:61-76:91-106.
Is there a way to notate this in the cor command so that the
2018 Jan 18
3
request for code
Hi,
I want to convert my MATLAB programs to R studio programs.
Kindly guide on the same.
[[alternative HTML version deleted]]
2007 Sep 27
1
to overcome error while computing sd for each subset of data (PR#9931)
Full_Name: Anjali Shitole
Version: R 2.5.1
OS:
Submission from: (NULL) (202.141.157.91)
I want to compute coefficient of variation for each subset of data.
Each subset is heterogeneous means number of rows in each subset are
different.These all subsets are in one dataset situated one by one.
i have used aggregate command to calculate mean for each subset.
But same command for calculating sd
2012 May 29
1
model frame and formula mismatch with latent class analysis poLCA
Dear R-users,
I keep getting an ERROR saying " Error in model.matrix.default(formula,
mframe) : model frame and formula mismatch in model.matrix() " when i fit
poLCA with more than 63 variables. Below are the details.
I am trying to do a Latent Class Analysis using poLCA. My data set contains
binary scores of, for instance, 200 students on 100 items. These numbers
could even be more
2008 Jan 24
0
(lme4: lmer) mcmcsamp: Error in if (var(y) == 0)
I've got a problem with "mcmcsamp" used with glmer objects produced
with "lmer" from the lme4 package.
When calling mcmcsamp, I get the error
Error in if (var(y) == 0) { : missing value where TRUE/FALSE needed
This does not occur with all models, but I can't find anything wrong
with the dataset.
If the error is in my data, can someone tell me what I am looking
2018 Feb 27
2
scale.default gives an incorrect error message when is.numeric() fails on a sparse row matrix (dgeMatrix)
I am attempting to use the lars package with a sparse input feature matrix,
but the following fails:
library(Matrix)
library(lars)
data(diabetes)
attach(diabetes)
x = as(as.matrix(as.data.frame(x)), 'dgCMatrix')
lars(x, y, intercept = FALSE)
Error in scale.default(x, FALSE, normx) :
>
> length of 'scale' must equal the number of columns of 'x'
>
>
More
2018 Mar 01
0
scale.default gives an incorrect error message when is.numeric() fails on a dgeMatrix
>>>>> Michael Chirico <michaelchirico4 at gmail.com>
>>>>> on Tue, 27 Feb 2018 20:18:34 +0800 writes:
Slightly amended 'Subject': (unimportant mistake: a dgeMatrix is *not* sparse)
MM: modified to commented R code, slightly changed from your post:
## I am attempting to use the lars package with a sparse input feature matrix,
## but the following
2010 Aug 24
5
Sweave.sty
Does anyone know where I can download the latest version of Sweave.sty? I have looked all over the site http://www.stat.umn.edu/~charlie/Sweave/ with no luck.