similar to: How does once import a function from an imported script?

Displaying 20 results from an estimated 10000 matches similar to: "How does once import a function from an imported script?"

2011 Jun 15
2
Trouble with compound functions---differential equations
Hi all, My apologies if this message is incredibly inept but I am very new to both computer programming and to R. I am working with the odesolve add-on and have the following function defined RVF_Single <- function(t, x, p) within the script I also have the following functions defined: T1<-function(t) {T1<-27.5-12.5*cos(2*pi*t/365)} and B1<-function(T1,t)
2012 Mar 26
2
y needing more than 2 functions
Dear all, I'm aware if y has two separate functions (depending on the conditions of x) you can use the ifelse function to separate y into two separate functions depending on input. How do you do this if there a multiple different conditions for x? for example, y fits the following between t>0 & t<15----->function(t) t^2, y fits the following between t>15 &
2011 Jul 22
1
Plotting compound functions--help with defining x-axis as f(x)
Hi all, I'm having trouble locating a script that will allow to me to create graphs that show compound functions as a function of the simple function, rather than just x (or time as it is in my case). Currently I have the following functions defined in my script: > > > T1<-function(t) {27.5-12.5*cos(2*pi*t/365)**} > and > > B1<-function(T1,t)
2007 Apr 05
1
Plotting multiple curves with lattice graphs
Hi List, I would like to plot multiple curves (parametric density curves) in one plot. For example: # parameters for three normal density curves parms = data.frame(ID=c(1,2,3),mu=c(50,55,60),sigma=c(10,12,15)) # I can easily draw three normal density curves using curve(): curve(dnorm(x,mean=parms$mu[1],sd=parms$sigma[1]),from=0, to=150, ylab="density", col="red")
2009 Sep 24
1
Fw: Re: Multiple Normal Curves
Sorry about the subject --- On Thu, 24/9/09, KABELI MEFANE <kabelimefane@yahoo.co.uk> wrote: From: KABELI MEFANE <kabelimefane@yahoo.co.uk> Subject: Re: [R] Multiply Normal Curves To: R-help@r-project.org Date: Thursday, 24 September, 2009, 11:48 AM R -helpers   i have been trying to do this problem without must success,i managed to do a graph for x, but it is not what i want to
2008 Jun 05
1
nls() newbie convergence problem
I'm sure this must be a nls() newbie question, but I'm stumped. I'm trying to do the example from Draper and Yang (1997). They give this snippet of S-Plus code: Specify the weight function: weight < - function(y,x1,x2,b0,b1,b2) { pred <- b0+b1*x1 + b2*x2 parms <- abs(b1*b2)^(1/3) (y-pred)/parms } Fit the model gmfit < -nls(~weight(y,x1,x2,b0,b1,b2),
2010 Jul 22
1
function return
I am sorry if this question is vague or uninformed. I am just learning R and struggling. I am using the book Hierarchical Modeling and Inference in Ecology and they provide examples of R code. I have the following code from the book but when I run it I don't get any output. I cannot get the values of 'out' to show up. Basically, I just want to see my estimates for b0,
2005 Oct 07
3
Converting PROC NLMIXED code to NLME
Hi, I am trying to convert the following NLMIXED code to NLME, but am running into problems concerning 'Singularity in backsolve'. As I am new to R/S-Plus, I thought I may be missing something in the NLME code. NLMIXED *********** proc nlmixed data=kidney.kidney; parms delta=0.03 gamma=1.1 b1=-0.003 b2=-1.2 b3=0.09 b4=0.35 b5=-1.43 varu=0.5; eta=b1*age+b2*sex+b3*gn+b4*an+b5*pkn+u;
2013 Feb 19
1
latin hypercube sampling
Hi all, I am attempting to use latin hypercube sampling to sample different variable functions in a series of simultaneous differential equations. There is very little code online about lhs or clhs, so from different other help threads I have seen, it seems I need to create a probability density function for each variable function, and then use latin hypercube sampling on this pdf. So far, I
2010 Sep 09
5
Help on simple problem with optim
Dear all, I ran into problems with the function "optim" when I tried to do an mle estimation of a simple lognormal regression. Some warning message poped up saying NANs have been produced in the optimization process. But I could not figure out which part of my code has caused this. I wonder if anybody would help. The code is in the following and the data is in the attachment. da <-
2006 Jul 25
1
HELP with NLME
Hi, I was very much hoping someone could help me with the following. I am trying to convert some SAS NLMIXED code to NLME in R (v.2.1), but I get an error message. Does anyone have any suggestions? I think my error is with the random effect "u" which seems to be parametrized differently in the SAS code. In case it's helpful, what I am essentially trying to do is estimate parameters
2010 Jul 06
1
plotmath vector problem; full program enclosed
Here's another example of my plotmath whipping boy, the Normal distribution. A colleague asks for a Normal plotted above a series of axes that represent various other distributions (T, etc). I want to use vectors of equations in plotmath to do this, but have run into trouble. Now I've isolated the problem down to a relatively small piece of working example code (below). If you would
2005 Nov 09
2
About: Error in FUN(X[[1]], ...) : symbol print-name too long
Hi, I??m trying to use the Win2BUGS package from R and I have a similar problem that reurns with the message: Error in FUN(X[[1]], ...) : symbol print-name too long But, there is no stray ` character in the file ( Sugestions given by: Duncan Temple Lang <duncan> Date: Mon, 26 Sep 2005 07:31:08 -0700 ) The progam in R is: library(R2WinBUGS) library(rbugs) dat <-
2008 Jun 14
1
restricted coefficient and factor in linear regression.
Hi, my data set is data.frame(id, yr, y, l, e, k). I would like to estimate Lee and Schmidts (1993, OUP) model in R. My colleague wrote SAS code as follows: ** procedures for creating dummy variables are omitted ** ** di# and dt# are dummy variables for industry and time ** data a2; merge a1 a2 a; by id yr; proc sysnlin maxit=100 outest=beta2; endogenous y; exogenous l e k
2009 Sep 08
1
optim() argument scoping: passing parameter values into user's subfunction
Dear useRs, I have a complicated function to be optimized with optim(), and whose parameters are passed to another function within its evaluation. This function allows for the parameters to enter as arguments to various probability distribution functions. However, I am violating some scoping convention, as somewhere within the hierarchy of calls a variable is not visible. I will give a
2010 Mar 20
2
EM algorithm in R
Please help me in writing the R code for this problem. I've been solving this for 4 days. It was hard for me to solve it. It's a simulation problem in R. The problem is My true model is a normal mixture which is given as 0.5 N(-0.8,1) + 0.5 N(0.8,1). This model has two components. I will get a random sample of size 100 from this model. I will do this 300 times. That means, I will have
2006 Apr 20
2
nlminb( ) : one compartment open PK model
All, I have been able to successfully use the optim( ) function with "L-BFGS-B" to find reasonable parameters for a one-compartment open pharmacokinetic model. My loss function in this case was squared error, and I made no assumptions about the distribution of the plasma values. The model appeared to fit pretty well. Out of curiosity, I decided to try to use nlminb( ) applied to a
2005 Jul 19
2
Michaelis-menten equation
Dear R users: I encountered difficulties in michaelis-menten equation. I found that when I use right model definiens, I got wrong Km vlaue, and I got right Km value when i use wrong model definiens. The value of Vd and Vmax are correct in these two models. #-----right model definiens-------- PKindex<-data.frame(time=c(0,1,2,4,6,8,10,12,16,20,24),
2006 Aug 08
1
Fitting data with optim or nls--different time scales
Hi, I have a system of ODE's I can solve with lsoda. Model=function(t,x,parms) { #parameter definitions lambda=parms[1]; beta=parms[2]; d = parms[3]; delta = parms[4]; p=parms[5]; c=parms[6] xdot[1] = lambda - (d*x[1])- (beta*x[3]*x[1]) xdot[2] = (beta*x[3]*x[1]) - (delta*x[2]) xdot[3] = (p*x[2]) - (c*x[3]) return(list(xdot)) } I want
2007 Mar 03
3
How to convert List object to function arguments?
Dear R gurus, I have a function "goftests" that receives the following arguments: * a vector "x" of data values; * a distribution name "dist"; * the dots list ("...") containing a list a parameters to pass to CDF function; and calls several goodness-of-fit tests on the given data values against the given distribution. That is: ##### BEGIN CODE SNIP #####