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. Error t value Pr(>|t|)

Y0 -0.0001821  0.0002886  -0.631    0.528

a   0.1669675  0.0015223 109.678   <2e-16 ***

m1 10.8045840  0.1575957  68.559   <2e-16 ***

---

Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Residual standard error: 0.007244 on 997 degrees of freedom


Number of iterations to convergence: 7

Achieved convergence tolerance: 4.214e-06



I would like to print this summary to a file but when I use cat it adds a
lot of the intermediate values and does not give me the Pvalues of the
t-test. Can you suggest a good way to print this to a file? I have used-


cat(paste(a), file="testing.txt", append = FALSE)


output in file:

wcorr ~ (Y0 + a * exp(m1 * -dist/100))

 c(0.168587967690081, 0.0410369885074373, 0.015604934198253,
0.00651400975192817, -0.00198358204504023, -0.00297164058538482,
0.00200403258235102, -0.00585536622301963, -0.00677164279240891,
-0.00663060500378226, -0.00429206279972985, -0.00752682816527953,
-0.00772771510594769, -0.0140235396260263, -0.00905111970710343,
-0.00527727528681396, -0.00637982823781946, -0.0101696023470134,
-0.0101074232949501, -0.00715411863549439, -0.00662351777569056,
-0.00284945195584713, -0.00401775422983583, -0.00833925944560227,

 0.00724377249911614

 c(3, 997)

 c(0.001587401493019, 3.32626693693668e-05, 0.412938194338572,
3.32626693693668e-05, 0.0441665508678859, 2.86654588531843,
0.412938194338572, 2.86654588531843, 473.324480704723)

 nls(formula = wcorr ~ (Y0 + a * exp(m1 * -dist/100)), start = pa1, control
= list(maxiter = 1000, tol = 1e-05, minFactor = 0.0009765625, printEval =
FALSE, warnOnly = TRUE), algorithm = "default", trace = FALSE)

 list(isConv = TRUE, finIter = 7, finTol = 4.21396379219722e-06, stopCode =
0, stopMessage = "converged")

 list(maxiter = 1000, warnOnly = TRUE)

 NULL

 c(-0.00018212632256334, 0.166967461792613, 10.8045839935834,
0.000288607886496774, 0.00152233960007251, 0.157595671762849,
-0.631051094181987, 109.678196497457, 68.5588878978997, 0.528151752824769,
0, 0)

 c(-0.00018212632256334, 0.166967461792613, 10.8045839935834,
0.000288607886496774, 0.00152233960007251, 0.157595671762849,
-0.631051094181987, 109.678196497457, 68.5588878978997, 0.528151752824769,
0, 0)

Thanks,

Diviya

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to