[R] LogLik of nls

2013-01-31 Thread Diviya Smith
Hello there, Can anyone point me to the code for logLik of an nls object? I found the code for logLik of an lm but could not find exactly what function is used for calculating the logLik of nls function? I am using the nls to fit the following model to data - Model 1: y ~ Ae^(-mx) + Be^(-nx) +c

[R] Legend symbols

2012-12-21 Thread Diviya Smith
Hi there, I was wondering if there is any R package that one can use for plotting that has more legend symbols - the standard pch has 18 symbols but I need ~30 for my application- and just using different colors is not an option. Thank you in advance, Diviya [[alternative HTML version

[R] nls for sum of exponentials

2012-12-16 Thread Diviya Smith
Hi there, I am trying to fit the following model with a sum of exponentials - y ~ Ae^(-md) + B e^(-nd) + c the model has 5 parameters A, b, m, n, c I am using nls to fit the data and I am using DEoptim package to pick the most optimal start values - fm4 - function(x) x[1] + x[2]*exp(x[3] *

[R] Rscript installing packages

2012-09-10 Thread Diviya Smith
Hi there I have an Rscript and I am looking for a way to install a package non-interactively. In Rscript {Utils}, I saw an example which does something like this, however this does not seem to work for my particular example. I am trying to install the following package in an Rscript (without

[R] Solving quadratic equation in R

2012-07-26 Thread Diviya Smith
Hi there, I would like to solve a simple equation in R a^2 - a = 8.313 There is no real solution to this problem but I would like to get an approximate numerical solution. Can someone suggest how I can set this up? Thanks in advance, Diviya [[alternative HTML version deleted]]

Re: [R] Solving quadratic equation in R

2012-07-26 Thread Diviya Smith
Sorry it is important for me to constrain the value of 'a' between c(0,1) On Thu, Jul 26, 2012 at 4:48 PM, Diviya Smith diviya.sm...@gmail.comwrote: Hi there, I would like to solve a simple equation in R a^2 - a = 8.313 There is no real solution to this problem but I would like to get

Re: [R] Solving quadratic equation in R

2012-07-26 Thread Diviya Smith
On Thu, Jul 26, 2012 at 5:16 PM, Diviya Smith diviya.sm...@gmail.comwrote: Thank you for pointing me to the uniroot function? Is there a way to constrain this solution so that it only gives me values of 'a' between c(0,1)? I tried using nlminb and for some reason it always estimates a = 0

[R] Solving equations in R

2012-07-23 Thread Diviya Smith
Hi there, I would like to solve the following equation in R to estimate 'a'. I have the amp, d, x and y. amp*y^2 = 2*a*(1-a)*(-a*d+(1-a)*x)^2 test data: amp = 0.2370 y= 0.0233 d= 0.002 x= 0.091 Can anyone suggest how I can set this up? Thanks, Diviya [[alternative HTML version

[R] Linear regression

2012-03-19 Thread Diviya Smith
Hello there, I am new to using regression in R. I wanted to solve a simple regression problem where I have 2 equations and 2 unknowns. So lets say - y1 = alpha1*A + beta1*B y2 = alpha2*A + beta2*B y1 - runif(10, 0,1) y2 - runif(10,0,1) alpha1 - 0.6 alpha2 - 0.75 beta1 - 1-alpha1 beta2

Re: [R] Linear regression

2012-03-19 Thread Diviya Smith
, Diviya Smith diviya.sm...@gmail.com wrote: Hello there, I am new to using regression in R. I wanted to solve a simple regression problem where I have 2 equations and 2 unknowns. So lets say - y1 = alpha1*A + beta1*B y2 = alpha2*A + beta2*B y1 - runif(10, 0,1) y2 - runif

[R] Strange plotting error

2012-02-14 Thread Diviya Smith
Hi there, I am trying to compute the autocorrelation in a dataset using R's acf function. ACF automatically plots the results. This works well except in some cases xlim doesnt work data - rnorm(2000,0,1) acf(data,xlim=c(1,10)) # works - the plot starts at 1 acf(data,lag=100,xlim=c(1,100)) #

[R] R function implementation

2011-12-07 Thread Diviya Smith
Hello there, I recently wrote some code to perform pairwise correlations between all samples in a large dataset. So we are talking about performing pairwise correlations between 400K vectors. Since R has a very rich library of functions, it was very easy to code this in R. However, R was probably

[R] Binning the data based on a value

2011-12-05 Thread Diviya Smith
Hello there, I have a matrix with some data and I want to split this matrix based on the values in one column. Is there a quick way of doing this? I have looked at cut but I am not sure how to exactly use it? for example: I would like to split the matrix a based on the spending such that the

Re: [R] Binning the data based on a value

2011-12-05 Thread Diviya Smith
) and you can include a round(a$spending, -2) or something similar if you want to group by the 100's. Michael On Mon, Dec 5, 2011 at 3:37 PM, Diviya Smith diviya.sm...@gmail.com wrote: Hello there, I have a matrix with some data and I want to split this matrix based

[R] barplot names.arg

2011-11-10 Thread Diviya Smith
Hello there, I have a question regarding bar plots. I am trying to plot the data from the following matrix as a barplot - # input data mdat - matrix(c(0.1,0.9,0.9,0.1,0.5,0.5,0.45,1-0.45,0.6,0.4,0.8,0.2), nrow = 6, ncol=2, byrow=TRUE, +dimnames = list(c(Mon, Mon, Tues, Tues,

Re: [R] barplot names.arg

2011-11-10 Thread Diviya Smith
(rownames(mdat)), function(n) colSums(mdat[n,,drop=F])), col = rainbow(2)) Michael On Thu, Nov 10, 2011 at 9:21 PM, Diviya Smith diviya.sm...@gmail.com wrote: Hello there, I have a question regarding bar plots. I am trying to plot the data from the following matrix as a barplot

[R] NLS- check convergence

2011-09-22 Thread Diviya Smith
Hi there, I am having some trouble with NLS convergence for my function. I was wondering if there is a way to check the value of the indicator function for all the iterations to look at the surface of the likelihood function. Any help would be most appreciated. Thanks, Diviya

[R] NLS error

2011-09-20 Thread Diviya Smith
Hello there, I am using NLS for fitting a complex model to some data to estimate a couple of the missing parameters. The model is - y ~ (C+((log(1-r))*exp(-A*d)*(-1+r+exp(d*(A-B)))/(r*(-A*d+d*B+log(1-r) where A, B and C are unknown. In order to test the model, I generate data by setting

Re: [R] NLS error

2011-09-20 Thread Diviya Smith
(form[[3L]], names(ind), env) : Missing value or an infinity produced when evaluating the model Any suggestions how to fix this? Diviya On Tue, Sep 20, 2011 at 2:37 PM, Jean V Adams jvad...@usgs.gov wrote: Diviya Smith wrote on 09/20/2011 01:03:22 PM: Hello there, I am using NLS

Re: [R] NLS error

2011-09-20 Thread Diviya Smith
suggestions? On Tue, Sep 20, 2011 at 5:59 PM, Diviya Smith diviya.sm...@gmail.comwrote: I dont think *r* is related to the problem. I am not trying to estimate *r * and so basically I am giving the model the correct value of *r* and so log(1-r) should not go to infinity. For test data, I generate

[R] Optimization package

2011-09-14 Thread Diviya Smith
Hi there, I have a complex math equation which does not have a closed form solution. It is - y - (p*exp(-a*d)*(1-exp((d-p)*(a-x[1]/((p-d)*(1-exp(-p*(a-x[1] For this equation, I have all the values except for x[1]. So I need to solve this problem numerically. Can anyone suggest an

[R] Print the summary of a model to file

2011-06-15 Thread Diviya Smith
Hi there, I am having a strange problem. I am running nls on some data. #data x - -(1:100)/10 y - 100 + 10 * (exp(-x / 2) Using nls I fit an exponential model to this data and get a great fit summary(fit) Formula: wcorr ~ (Y0 + a * exp(m1 * -dist/100)) Parameters: Estimate Std.

[R] NLS fit for exponential distribution

2011-06-12 Thread Diviya Smith
Hello there, I am trying to fit an exponential fit using Least squares to some data. #data x - c(1 ,10, 20, 30, 40, 50, 60, 70, 80, 90, 100) y - c(0.033823, 0.014779, 0.004698, 0.001584, -0.002017, -0.003436, -0.06, -0.004626, -0.004626, -0.004626, -0.004626) sub -

[R] Likelihood ratio test

2011-06-12 Thread Diviya Smith
Hello there, I want to perform a likelihood ratio test to check if a single exponential or a sum of 2 exponentials provides the best fit to my data. I am new to R programming and I am not sure if there is a direct function for doing this and whats the best way to go about it? #data x - c(1 ,10,

[R] Error in NLS example in the documentation

2011-06-12 Thread Diviya Smith
Hello there, I am trying to use R function NLS to analyze my data and one of the examples in the documentation is - ## the nls() internal cheap guess for starting values can be sufficient: x - -(1:100)/10 y - 100 + 10 * exp(x / 2) + rnorm(x)/10 nlmod - nls(y ~ Const + A * exp(B * x),

Re: [R] NLS fit for exponential distribution

2011-06-12 Thread Diviya Smith
(fit1, fit2) HTH, Dennis On Sun, Jun 12, 2011 at 9:57 AM, Diviya Smith diviya.sm...@gmail.com wrote: Hello there, I am trying to fit an exponential fit using Least squares to some data. #data x - c(1 ,10, 20, 30, 40, 50, 60, 70, 80, 90, 100) y - c(0.033823, 0.014779