[R] force pdf()

2013-08-14 Thread Christof Kluß

Hi

is there a way to generate a pdf, e.g. pdf(test.pdf), even if the file 
test.pdf is open? (e.g. with acrobat)


i.e. I would have to close test.pdf in the viewer without any user 
interaction, than override the file and maybe open it again.


thx
Christof

__
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.


[R] optimize integer function parameters

2013-07-23 Thread Christof Kluß

Hi

I have observations obs - (11455, 11536, 11582, 11825, 11900,  ...)

and a simulation function f(A,B,C,D,E,F), so sim - f(A,B,C,D,E,F)

e.g. sim = c(11464, 11554, 11603, 11831, 11907, ...)

now I would like to fit A,B,C,D,E,F such that obs and f(A,B,C,D,E,F) 
match as well as possible. A,..,F should be integers and have bounds.


How would you solve this problem without bruteforce in an acceptable time?

thx
Christof

__
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.


Re: [R] optimize integer function parameters

2013-07-23 Thread Christof Kluß

Hi

the integer values in the vectors sim and obs are dates

when I set sim - f(TS0,TS1,TS2,TB0,TB1,TB2) my A,..,F below
then TS0 and TB0 are depend (and so on)


the main thing in f(...) is something like

 for (i in c(1:length(temperature))) {
  Temp - temperature[i]
  if (DS  0) {
DS - DS + max(Temp-TB0,0) / TS0
  } else if (DS  1) {
... date0 - i
DS - DS + max(Temp-TB1,0) / TS1
  } else if (DS  2) {
... date1 - i
DS - DS + max(Temp-TB2,0) / TS2
  } else {
... date2 - i
break
  }
}


this produced a vector sim = c(date0,date1,date2,...)


now I would like to minimize RMSE(sim,obs) or something like that

thx
Christof



for brute force I would do something like

obs - ...
act - 1000

  for (TS0 in seq(50,100,10))
for (TS1 in seq(750,850,10))
  for (TS2 in seq(400,600,10))
for (TB0 in c(5:7))
  for (TB1 in c(5:7))
for (TB2 in c(4:9)) {
  sim - foosim(dat,TS0,TS1,TS2,TB0,TB1,TB2)
  rmse - sqrt(mean((sim - obs)^2, na.rm = TRUE))

  if (rmse  act) {
print(paste(rmse,TS0,TS1,TS2,TB0,TB1,TB2))
act - rmse
  }
}


Am 23-07-2013 13:20, schrieb Enrico Schumann:

On Tue, 23 Jul 2013, Christof Kluß ckl...@email.uni-kiel.de writes:



I have observations obs - (11455, 11536, 11582, 11825, 11900,  ...)

and a simulation function f(A,B,C,D,E,F), so sim - f(A,B,C,D,E,F)

e.g. sim = c(11464, 11554, 11603, 11831, 11907, ...)

now I would like to fit A,B,C,D,E,F such that obs and f(A,B,C,D,E,F)
match as well as possible. A,..,F should be integers and have bounds.

How would you solve this problem without bruteforce in an acceptable time?




That depends on what your simulation function looks like.  Could you
post a (small) self-contained example?




__
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.


[R] make R program faster

2013-03-28 Thread Christof Kluß

Hi

there are some good tips in The R Inferno
http://www.burns-stat.com/documents/books/the-r-inferno/
or connect C++ to R with Rcpp
http://dirk.eddelbuettel.com/code/rcpp.html
or byte code compiler (library(compiler))
or library(data.table)

but do you have an idea to fasten standard R source code, with the 
following Rprof output


self.time self.pct total.time total.pct
[-.data.frame   1.3429.13   1.78 38.70
[.data.frame 0.26 5.65   1.02 22.17
[[   0.12 2.61   0.44  9.57
NextMethod   0.12 2.61   0.12  2.61
match0.10 2.17   0.16  3.48
Anonymous  0.10 2.17   0.10  2.17
c0.10 2.17   0.10  2.17
[[.data.frame0.08 1.74   0.32  6.96
[.Date   0.06 1.30   0.10  2.17
FUN  0.06 1.30   0.10  2.17
[-  0.04 0.87   1.82 39.57
[0.04 0.87   1.04 22.61
[-.Date 0.04 0.87   0.18  3.91
vapply   0.04 0.87   0.14  3.04
%in% 0.02 0.43   0.18  3.91
+0.02 0.43   0.10  2.17


It comes from a simulation algorithmus that calculates day wise values 
(values are depenend from the output of the day before). First I create 
a data.frame with NAs. Finally each row contains the daily values.


output - as.data.frame(matrix(nrow = 365, ncol = 50))
for (day in (1:365)) {
  ...
  r - list(Date=d,daylength=daylength,TempSum=tempsum, ...)
  output[day,] - r
}

Is there an better (faster) way to do such things in R?

Greetings
Christof

__
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.


Re: [R] read tab delimited file from a certain line

2013-01-20 Thread Christof Kluß

Hi Henrik,

that's perfect, thanks!

Greetings
Christof

Am 18-01-2013 19:26, schrieb Henrik Bengtsson:

Christof,

I've added support for this to the R.filesets package.  In your case,
then all you need to do is:

library(R.filesets)
dlf - readDataFrame(filename, skip=^year)

No need to specify any other arguments - they're all automagically
inferred - and the default is stringsAsFactors=FALSE.

This is in R.filesets v2.0.0 which I still haven't published on CRAN.
In the meanwhile, you can install it via:

source(http://aroma-project.org/hbLite.R;)
hbLite(R.filesets)

/Henrik

On Thu, Jan 17, 2013 at 1:34 AM, Christof Kluß ckl...@email.uni-kiel.de wrote:

Hello

thank you for the fast and helpful answer! Now the following works fine for
me

x - readLines(filename)

i - grep(^year, x)
dlf - read.table(textConnection(x[i:length(x)]),
header = T, stringsAsFactors=F,sep=\t)

Greetings
Christof


Am 16-01-2013 16:55, schrieb Rui Barradas:


Hello,

Read the file using readLines, then grep ^year. You can then use a
textConnection to read.table:

x - readLines(con = textConnection(
informations (unknown count of lines)
... and at some point the table
--
year month mday value
2013 1 16 0 ))

# This is it
i - grep(^year, x)
read.table(textConnection(x[i:length(x)]), header = TRUE)


Hope this helps,

Rui Barradas

Em 16-01-2013 14:17, Christof Kluß escreveu:


Hi

I would like to read table data from a text-files with extra
informations in the header (of unknown line count). Example:

informations (unknown count of lines)
... and at some point the table
--
year month mday value
2013 1 16 0
...

If it was an excel file I could use something like read.xls(...,
pattern=year) But it is a simple tab seperated text-file. Is there
an easy way to read only the table? (Without dirty things ;))

Thx
Christof

__
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.





__
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.




__
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.


Re: [R] read tab delimited file from a certain line

2013-01-17 Thread Christof Kluß

Hello

thank you for the fast and helpful answer! Now the following works fine 
for me


x - readLines(filename)
i - grep(^year, x)
dlf - read.table(textConnection(x[i:length(x)]),
   header = T, stringsAsFactors=F,sep=\t)

Greetings
Christof


Am 16-01-2013 16:55, schrieb Rui Barradas:

Hello,

Read the file using readLines, then grep ^year. You can then use a
textConnection to read.table:

x - readLines(con = textConnection(
informations (unknown count of lines)
... and at some point the table
--
year month mday value
2013 1 16 0 ))

# This is it
i - grep(^year, x)
read.table(textConnection(x[i:length(x)]), header = TRUE)


Hope this helps,

Rui Barradas

Em 16-01-2013 14:17, Christof Kluß escreveu:

Hi

I would like to read table data from a text-files with extra
informations in the header (of unknown line count). Example:

informations (unknown count of lines)
... and at some point the table
--
year month mday value
2013 1 16 0
...

If it was an excel file I could use something like read.xls(...,
pattern=year) But it is a simple tab seperated text-file. Is there
an easy way to read only the table? (Without dirty things ;))

Thx
Christof

__
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.




__
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.


[R] read tab delimited file from a certain line

2013-01-16 Thread Christof Kluß

Hi

I would like to read table data from a text-files with extra 
informations in the header (of unknown line count). Example:


informations (unknown count of lines)
... and at some point the table
--
year month mday value
2013 1 16 0
...

If it was an excel file I could use something like read.xls(..., 
pattern=year) But it is a simple tab seperated text-file. Is there an 
easy way to read only the table? (Without dirty things ;))


Thx
Christof

__
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.


[R] connect points in charts

2012-10-26 Thread Christof Kluß
Hi

is there a automatic way that long distances between points are not
connected. I have something like

plot(x,y,type=o,...)

atx - seq(as.Date(2009-04-01),as.Date(2011-04-01),month)

axis.Date(1, at=atx,labels=format(atx, %b\n%Y),  padj=0.5 )

but I do not want lines between points whose distance is greater than
two weeks.

thx
Christof

__
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.


[R] mark sections on a time chart

2012-10-20 Thread Christof Kluß
Hi

is there a comfortable way to mark periods on time chart (axis.Date)?

To do it with arrows(...), seems to be irritating.

I want to have something like

---winterspringsummer--

thx
Christof

__
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.


Re: [R] mark sections on a time chart

2012-10-20 Thread Christof Kluß
Hello Rui Barradas

thank you very much. That is exactly what I was looking for.

Christof

Am 20-10-2012 14:19, schrieb Rui Barradas:
 library(zoo)
 
 arrowsRange - function(from, to, at = 1, labels = NULL,
 length = 1/8, horizontal = TRUE, border = FALSE, ...){
 require(plotrix)
 f1 - function(){
 if(horizontal)
 arrows(from, at, to, at, length = length, code = 3, ...)
 else
 arrows(at, from, at, to, length = length, code = 3, ...)
 }
 f2 - function(){
 f1()
 if(horizontal){
 x - rowMeans(cbind(from, to))
 y - at
 }else{
 x - at
 y - rowMeans(cbind(from, to))
 }
 boxed.labels(x, y, labels = labels, border = border)
 }
 if(is.null(text)) f1() else f2()
 }
 
 
 # Make up some test data
 set.seed(9365)
 z - zoo(cumsum(rnorm(365)))
 index(z) - Sys.Date() + 1:365
 start - as.Date(c(2012-12-21, 2013-03-21, 2013-06-22))
 end - as.Date(c(2013-03-20, 2013-06-21, 2013-09-21))
 seasons - c(Winter, Spring, Summer)
 
plot(z)
abline(v = c(start[1], end))
arrowsRange(start, end, at = 0, labels = seasons)

__
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.


[R] lattice xyplot, get current level

2012-10-02 Thread Christof Kluß
Hi

xyplot(y ~ x | subject) plots a separate graph of y against x for each
level of subject. But I would like to have an own function for each
level. Something like

xyplot(y ~ x | subject,
   panel = function(x,y) {
 panel.xyplot(x,y)

 panel.curve(x,y) {
   # something that dependents on the current subject
   ...
 }
   })


How I get the current subject? (The current subject is the title of the
graph, too)

thx
Christof

__
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.


Re: [R] lattice xyplot, get current level

2012-10-02 Thread Christof Kluß
subj - levels(subject)
subj[panel.number()]

seems to be a good solution

is there something like panel.legend (instead of panel.text)?

Am 02-10-2012 12:59, schrieb Christof Kluß:
 Hi
 
 xyplot(y ~ x | subject) plots a separate graph of y against x for each
 level of subject. But I would like to have an own function for each
 level. Something like
 
 xyplot(y ~ x | subject,
panel = function(x,y) {
  panel.xyplot(x,y)
 
  panel.curve(x,y) {
# something that dependents on the current subject
...
  }
})
 
 
 How I get the current subject? (The current subject is the title of the
 graph, too)
 
 thx
 Christof


__
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.


[R] nlme function examples for dose-respone

2012-09-25 Thread Christof Kluß
Hi,

I want to fit nonlinear dose-response curves, as fun(X,a,b,c), for
each of our 5 trail locations. Our data basis is something like

location plot year dose response

For each location there are 4 plots as repetitions (over 3 years). So
the interactions location*year and location*plot should be random
effects.

There are some examples in Mixed-Effects Models in S and S-PLUS
(Pinheiro and Bates), but I do not see how they can help me for my
model. Of course I can start with something like

mod - nlme(response ~ fun(dose,a,b,c)
, fixed = list(a ~ 1, b ~ 1, c ~ 1)
, random = list(a ~ 1, b ~ 1, c ~ 1)
, groups = ~location
, data=dat
, start= ... )

But that is not what I want. How do you describe that you want one fit
for each of the five locations and that location*year and
location*plot or something similar are random effects?

Do you have some other examples that fit better to this problem setting?
I welcome any tips.

thx
Christof

__
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.


Re: [R] nlme function examples for dose-respone

2012-09-25 Thread Christof Kluß
Hi,

thx Bert, I forward the question. I forgot a detail. For each (location,
plot, year) combination there are 6 (dose, response) pairs.

$ plot: Factor w/ 4 levels 1,2,3,4:
$ location : Factor w/ 5 levels loc1,loc2,..:
$ year: Factor w/ 3 levels 2009,2010,..:
$ dose: num  27.3 32.7 57.2 33 183.1 ...
$ response: num  54.2 64.9 74.3 62 92.2 ...

So I can fit each (location, plot, year) with 6 points and make a bottom
up approach. But I would be glad to have one overall model, like

mod - nlme(response ~ fun(dose,a,b,c)
 , fixed = list(a ~ 1, b ~ 1, c ~ 1)
 , random = list(a ~ 1, b ~ 1, c ~ 1)
 , groups = ~location
 , data=dat
 , start= ... )

and location*plot and location*year as random and for each location
one best fitted curve. But unfortunately I did not know how to formulate
this in nlme.

Christof


Am 25-09-2012 18:13, schrieb Bert Gunter:
 1. Post on R-sig-mixed-models instead. Much more expertise and relevance 
 there.
 
 2. I would forget about mixed effects and treat the locations as
 fixed. With only 5, you don't have enough information  to estimate the
 variance component with any precision anyway.
 
 3. Feel free to ignore (2) and defer to the experts at (1).
 
 Cheers,
 Bert
 
 
 On Tue, Sep 25, 2012 at 8:52 AM, Christof Kluß ckl...@email.uni-kiel.de 
 wrote:
 Hi,

 I want to fit nonlinear dose-response curves, as fun(X,a,b,c), for
 each of our 5 trail locations. Our data basis is something like

 location plot year dose response

 For each location there are 4 plots as repetitions (over 3 years). So
 the interactions location*year and location*plot should be random
 effects.

 There are some examples in Mixed-Effects Models in S and S-PLUS
 (Pinheiro and Bates), but I do not see how they can help me for my
 model. Of course I can start with something like

 mod - nlme(response ~ fun(dose,a,b,c)
 , fixed = list(a ~ 1, b ~ 1, c ~ 1)
 , random = list(a ~ 1, b ~ 1, c ~ 1)
 , groups = ~location
 , data=dat
 , start= ... )

 But that is not what I want. How do you describe that you want one fit
 for each of the five locations and that location*year and
 location*plot or something similar are random effects?

 Do you have some other examples that fit better to this problem setting?
 I welcome any tips.

 thx
 Christof

 __
 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.
 
 


__
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.


Re: [R] eval(parse(...)) only once in a function

2012-09-18 Thread Christof Kluß
Hi Thomas

thx, already the e - parse(text=df$str==12)[[1]] is nice. So I have
not to call parse in my function! (The function is called very often, so
it makes the program much faster.)

And eval(bquote(function(df) b-.(e))) is great! That's exactly what I
was looking for.


Christof


Am 17-09-2012 22:52, schrieb Thomas Lumley:
 On Mon, Sep 17, 2012 at 6:27 PM, Christof Kluß ckl...@email.uni-kiel.de 
 wrote:
 but for performance eval(parse(a)) should not be evaluated at each
 function call, but should work as
 
 You can do it with bquote()
 
 e-parse(text=df$str==12)[[1]]
 e
 df$str == 12
 bquote(function(df) b-.(e))
 function(df) b - df$str == 12

 eval(bquote(function(df) b-.(e)))
 function (df)
 b - df$str == 12
 
 This saves more time than I expected, about 100ms per evaluation on my
 computer.

__
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.


[R] eval(parse(...)) only once in a function

2012-09-17 Thread Christof Kluß
Hi

I would like to have something like

str - df$JT == 12

fun - function(df) {

  b - eval(parse(str))

  return(b)
}

but for performance eval(parse(a)) should not be evaluated at each
function call, but should work as

fun - function(df) {

  b - df$JT == 12

  return(b)
}

Do you have an idea how I can implement this?

Thx
Christof

__
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.


[R] self-starter functions for y = a + b * c^x

2012-08-14 Thread Christof Kluß
Hi

there are some predefined self-start functions, like SSmicmen, SSbiexp,
SSasymp, SSasympOff, SSasympOrig, SSgompertz, SSflp, SSlogis, SSweibull,
Quadratic, Qubic, SSexp (nlrwr)

Btw, do you know graphic examples for this functions?

The SSexpDecay (exponential decay) for y = (y0 - plateau)*exp(-k*x) +
plateau from
http://stats.stackexchange.com/questions/17126/how-can-i-make-my-r-nls-model-more-stable
works fine, too.

But now I search a self-starter for y = a + b * c^x

Do you know a package that implement such self-starter or is there a
easy way to do it myself?

thx
Christof

__
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.


Re: [R] self-starter functions for y = a + b * c^x

2012-08-14 Thread Christof Kluß
Hi Ken

Am 14-08-2012 11:50, schrieb ken knoblauch:
 Christof Kluß ckluss at email.uni-kiel.de writes:
 
 But now I search a self-starter for y = a + b * c^x
 
 You might be able to adapt the SS.calib function
  from the psyphy package for this.  
 It was designed to fit gamma functions to the 
 luminance vs frame buffer values measured on CRT
 screens.  But the functional form is similar.

thank you for the hint. I will test that function too. But it seems to
be something like y = a + b * x^c and not y = a + b * c^x

Greetings
Christof

__
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.


Re: [R] self-starter functions for y = a + b * c^x

2012-08-14 Thread Christof Kluß
Am 14-08-2012 19:40, schrieb Peter Ehlers:
 On 2012-08-14 00:09, Christof Kluß wrote:
 But now I search a self-starter for y = a + b * c^x
 Can't you just reparameterize with  c^x = exp(x * log(c)) ?

oh, I've missed this... thank you very much!

Greetings
Christof

__
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.


[R] alternative to rbind for data.table

2012-07-21 Thread Christof Kluß
Hi

I want to add a row to a data.table in each round of a for loop.
rbind seems to be a inefficient way to implement this.

How would you do this? The slow solution:

library(data.table)
Rprof(test.out)
dt - data.table()

for (i in (1:1)) {
  # algorithm that generates a list with different values,
  # but same key-names, each round, for example
  l - list(A=1,B=2,C=3,E=4,F=5)
  dt - rbind(dt,l) # very slow :(
}

Rprof(NULL)
summaryRprof(test.out)

thx
Christof

__
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.


Re: [R] save conditions in a list

2012-07-06 Thread Christof Kluß
Hi Rui Barradas

thank you very much, that's what I searched for

result - lapply(conds, fun, DF) works, if

day - DF$day
val - DF$val

Thanks
Christof




Am 02-07-2012 20:44, schrieb Rui Barradas:
 Hello,
 
 I'm not sure if this is what you want.
 
 
 #-- Make up a dataset
 set.seed(1)
 n - 1e2
 DF - data.frame(year=2010 + sample(3, n, TRUE),
 day=sample(365, n, TRUE),
 val=sample(100, n, TRUE))
 
 a = day  100; b = val  50; c = year == 2012
 conds - list(a=a, b=b, c=c)
 
 #-- This does it
 fun - function(condition, x){
 f - function(){}
 if(class(x) == matrix) x - data.frame(x)
 if(class(x) == data.frame)
 body(f) - with(x, parse(text=condition))
 else
 body(f) - parse(text=condition)
 f()
 }
 
 #-- Test the function
 year - DF$year # See if it works with vectors
 fun(b, year)# Must throw error
 fun(c, year)# Should work
 
 # And now with data.frames
 result - lapply(conds, fun, DF)
 
 Reduce(``, result) # combine the results
 Reduce(`|`, result) #
 
 
 Hope this helps,
 
 Rui Barradas
 
 Em 02-07-2012 18:04, Christof Kluß escreveu:
 Hi

 how would you save conditions like

 a = day  100; b = val  50; c = year == 2012

 in a list? I like to have variables like day, val, year and a list
 of conditions list(a,b,c). Then I want to check if a  b  c is true or
 if a | b | c is true or similar things.

 Greetings
 Christof

 __
 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.



__
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.


[R] save conditions in a list

2012-07-02 Thread Christof Kluß
Hi

how would you save conditions like

a = day  100; b = val  50; c = year == 2012

in a list? I like to have variables like day, val, year and a list
of conditions list(a,b,c). Then I want to check if a  b  c is true or
if a | b | c is true or similar things.

Greetings
Christof

__
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.


[R] lm without intercept, false R-squared

2012-06-27 Thread Christof Kluß
Hi

is there a command that calculates the correct adjusted R-squared, when
I work without intercept? (The R-squared from lm without intercept is
false.)

Greetings
Chrsitof

__
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.


Re: [R] lm without intercept, false R-squared

2012-06-27 Thread Christof Kluß

for example the same model with intercept R² = 0.6, without intercept R²
= 0.9 and higher. In my definition of R², R² has to be equal or less
without intercept

I do not know what R shows, but in the summary of the model without
intercept it does not show the R² of the regression line.

When I run a regression I like to have the R² of the regression line and
not something else. ;)




Am 27-06-2012 10:25, schrieb Uwe Ligges:
 
 
 On 27.06.2012 09:33, Christof Kluß wrote:
 Hi

 is there a command that calculates the correct adjusted R-squared, when
 I work without intercept? (The R-squared from lm without intercept is
 false.)
 
 Then we need your definition of your version of correct - we know the
 definition of your version of false.
 
 Best,
 Uwe Ligges
 
 

 Greetings
 Chrsitof

 __
 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.

 
 


-- 
Dipl.-Inf. Christof Kluß (Raum 223) | Universität Kiel
Inst. für Pflanzenbau und -züchtung | www.gfo.uni-kiel.de
Grünland u. Futterbau/Ökol. Landbau | ckl...@gfo.uni-kiel.de
Hermann-Rodewald Str. 9, 24118 Kiel | Tel. 0431 880-2197

__
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.


Re: [R] lm without intercept, false R-squared

2012-06-27 Thread Christof Kluß

for example the same model with intercept R² = 0.6, without intercept R²
= 0.9 and higher. In my definition of R², R² has to be equal or less
without intercept

I do not know what R shows, but in the summary of the model without
intercept it does not show the R² of the regression line.

When I run a regression I like to have the R² of the regression line and
not something else. ;)




Am 27-06-2012 10:25, schrieb Uwe Ligges:
 
 
 On 27.06.2012 09:33, Christof Kluß wrote:
 Hi

 is there a command that calculates the correct adjusted R-squared, when
 I work without intercept? (The R-squared from lm without intercept is
 false.)
 
 Then we need your definition of your version of correct - we know the
 definition of your version of false.
 
 Best,
 Uwe Ligges
 
 

 Greetings
 Chrsitof

 __
 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.

 
 


-- 
Dipl.-Inf. Christof Kluß (Raum 223) | Universität Kiel
Inst. für Pflanzenbau und -züchtung | www.gfo.uni-kiel.de
Grünland u. Futterbau/Ökol. Landbau | ckl...@gfo.uni-kiel.de
Hermann-Rodewald Str. 9, 24118 Kiel | Tel. 0431 880-2197

__
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.


[R] visualize correlation matrix

2012-06-17 Thread Christof Kluß
Hi

is there a easy way to get something like
http://addictedtor.free.fr/graphiques/graphcode.php?graph=137

pairs(USJudgeRatings[,c(2:3,6,1,7)],
  lower.panel=panel.smooth, upper.panel=panel.cor)

but without the lower.panel (and without numbers and ticks at the border.)

thx
Christof

__
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.


[R] lme: extract result-function

2012-06-13 Thread Christof Kluß
Hi,

mod - lme(A ~ -1 + B+C+D+E+F+G, random = ~1 | ...)

results in summary(mod)$coeff

B C D E F G (Intercept)
b c d e f g i

Now I'm interested in the function

f - function(B,C,D,E,F,G) - {
  return(i + b*B + c*C + d*D + e*E + f*F + g*G)
}

Is there a easier way to create such function with flexible number of
coefficient, than do it by hand?

thx
Christof

__
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.


[R] plotting dates, incorrectly scaled x-axis?

2012-02-12 Thread Christof Kluß
Hi,

I want to plot with axis.Date(), but something is scaled incorrectly.
The red vertical line in is put on a totally wrong position. (sample below)

Do you have an idea what I'm doing wrong?

Thx
Christof


x11(width=30, height=20)

x-seq(as.Date(2010-02-27), as.Date(2011-03-28),month)
y - seq(0,100,length=length(x))

plot(y ~ x, type=o, tck=1, xaxt=n)

axis.Date(1, at=x, labels=format(x,%b\n%Y), padj=0.5)

abline(v=as.Date(2011-01-01), col=red, lty=dashed)

__
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.


[R] plotting dates, incorrectly scaled x-axis?

2012-02-12 Thread Christof Kluß
Hi,

I want to plot with axis.Date(), but something is scaled incorrectly.
The red vertical line in is put on a totally wrong position. (sample below)

Do you have an idea what I'm doing wrong?

Thx
Christof


x11(width=30, height=20)

x-seq(as.Date(2010-02-27), as.Date(2011-03-28),month)
y - seq(0,100,length=length(x))

plot(y ~ x, type=o, tck=1, xaxt=n)

axis.Date(1, at=x, labels=format(x,%b\n%Y), padj=0.5)

abline(v=as.Date(2011-01-01), col=red, lty=dashed)
attachment: plot.png__
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.


[R] visualize lme results

2012-01-22 Thread Christof Kluß
Hi

for each measurement day we use lme for our four repetitions. Now it
would be great if we can represent the error too.

The following seems to be good. Unfortunately, there is not the full
example source code. Maybe someone has done it before.

(from http://anthony.darrouzet-nardi.net/scienceblog/?p=406 )
Finally, here's a graph of the results for the ammonium data, showing
the mean differences±95%CI between each of our three treatments and the
control

http://anthony.darrouzet-nardi.net/scienceblog/wp-content/uploads/2011/08/rm_analysis_demo.png

thx
Christof

__
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.


[R] break an axis.POSIXct

2012-01-20 Thread Christof Kluß
Hi

I like to use axis.POSIXct to plot days from 2006 till 2008. But I
only have datas for the summer months. Is it possible to get two axis
breaks, to have not so long distances without points?

thx
Christof

__
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.


Re: [R] selection part of subset

2012-01-09 Thread Christof Kluß
Hi

thank you very much for your useful answers! In this case I solved it
with Sarah's suggestion

tab[tab[[name]] == v,]

that works fine

Greetings
Christof



Am 05-01-2012 16:51, schrieb Christof Kluß:
 Hi
 
 I want to do something like
 
 a - c(10,20,15,43,76,41,25,46)
 tab - data.frame(a)
 
 name - a
 
 for (v in unique(tab[[name]])) {
   r - subset(tab, name==v)   # this does not work
   ...
 }
 
 i.e. a string on the left side of the select expression (subset). How
 could I solve this?
 
 thx
 Christof


__
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.


[R] RODBC vs gdata

2012-01-09 Thread Christof Kluß
Hi

one col in my Excel file contains many numbers. But on line 3000 and
some other lines are strings like FG 1. RODBS seems to omit this
lines. gdata works, but is much slower.

Is this a bug of RODBC or do I apply it wrong?

Example with the same file.xlsx


library(RODBC); excel - odbcConnectExcel2007(file.xlsx)
tab - sqlQuery(excel, 'select * from Table 1$'); str(tab)

col1: num  1 2 3 4 5 6 7 8 9 10 ...

library(gdata); tab - read.xls(file.xlsx, sheet=1); str(tab)

col1: Factor w/ 51 levels 1,10,11,..: 1 12 23 34 41 42 43...


greeting
Christof

__
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.


Re: [R] RODBC vs gdata

2012-01-09 Thread Christof Kluß
Hi Enrico,

thank you very much, so it is a known problem with the Microsoft Excel
ODBC drivers :(

7 Excel Drivers
... There are at least two known problems with reading columns that do
not have a format set before data entry, and so start with format
`General'. First, the driver uses the first few rows to determined the
column type, and is over-fond of declaring `Numeric' even when there are
non-numeric entries. ... Second, if a column is declared as `Text',
numeric entries will be read as SQL nulls and hence R NAs.
Unfortunately, in neither case does reformatting the column help.

So I think I have to use gdata to be sure to read all datas.

regards
Christof


Am 09-01-2012 19:29, schrieb Enrico Schumann:
 
 Hi Christof,
 
 have a look at the manual of RODBC, and in particular the section on
 Excel drivers.
 
 RShowDoc(RODBC, package=RODBC)
 
 Regards,
 Enrico
 
 
 Am 09.01.2012 19:02, schrieb Christof Kluß:
 Hi

 one col in my Excel file contains many numbers. But on line 3000 and
 some other lines are strings like FG 1. RODBS seems to omit this
 lines. gdata works, but is much slower.

 Is this a bug of RODBC or do I apply it wrong?

 Example with the same file.xlsx


 library(RODBC); excel- odbcConnectExcel2007(file.xlsx)
 tab- sqlQuery(excel, 'select * from Table 1$'); str(tab)

 col1: num  1 2 3 4 5 6 7 8 9 10 ...

 library(gdata); tab- read.xls(file.xlsx, sheet=1); str(tab)

 col1: Factor w/ 51 levels 1,10,11,..: 1 12 23 34 41 42 43...


 greeting
 Christof

 __
 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.



__
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.


[R] selection part of subset

2012-01-05 Thread Christof Kluß
Hi

I want to do something like

a - c(10,20,15,43,76,41,25,46)
tab - data.frame(a)

name - a

for (v in unique(tab[[name]])) {
  r - subset(tab, name==v)   # this does not work
  ...
}

i.e. a string on the left side of the select expression (subset). How
could I solve this?

thx
Christof

__
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.


Re: [R] selection part of subset

2012-01-05 Thread Christof Kluß
Hi

the output should look like r - subset(tab, a==v)
but now I have something like   r - subset(tab, a==v)
and r - subset(tab, [[a]]==v)
does not work :(

greetings
Christof

Am 05-01-2012 16:51, schrieb Christof Kluß:
 Hi
 
 I want to do something like
 
 a - c(10,20,15,43,76,41,25,46)
 tab - data.frame(a)
 
 name - a
 
 for (v in unique(tab[[name]])) {
   r - subset(tab, name==v)   # this does not work
   ...
 }
 
 i.e. a string on the left side of the select expression (subset). How
 could I solve this?
 
 thx
 Christof


__
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.


[R] clear plot linear mixed model

2012-01-02 Thread Christof Kluß

Hi,

first a happy new year ;)

I would like to plot the regression lines of a model like

lme - lme(conc ~ name/time - 1, 
random=conc~time|nr,method=ML,data=measurements)


Ideally a seperate plot for each regression line (respectively name) and 
seperate colors for the measurements (nr).


How would you do that?

thx
Christof

__
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.


Re: [R] clear plot linear mixed model

2012-01-02 Thread Christof Kluß

Am 02-01-2012 10:54, schrieb ken knoblauch:

Christof Klußcklussat  email.uni-kiel.de  writes:


lme- lme(conc ~ name/time - 1,
random=conc~time|nr,method=ML,data=measurements)



see plot.augPred in the nlme package


thx, but how to set primary? I always get the error

plot(augPred(lme))

  augPred.lme without primary can only be used with fits of 
groupedData objects


greetings
Christof

__
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.


[R] apply on function with vector as result

2011-12-09 Thread Christof Kluß

Hi,

a have some code like

myfunc - function(x) { ...;  return c(a,b) }

ys - sapply(0:100,myfunc)

so I get something like c(c(a1,b1),c(a2,b2),...)

But now I need the as and bs in one vector

as - apply(ys, function(c(a,b)) a)
bs - apply(ys, function(c(a,b)) b)

Can you help me with the correct syntax, instead of my pseudo code?

thx
Christof

__
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.


Re: [R] apply on function with vector as result

2011-12-09 Thread Christof Kluß

Am 09-12-2011 12:54, schrieb Sarah Goslee:
 myfunc- function(x) {a=x; b=x-1; c(a, b) }
 ys- sapply(1:5, myfunc)
 ys
   [,1] [,2] [,3] [,4] [,5]
 [1,]12345
 [2,]01234

 And from there, it's not at all clear what you mean by one vector -
 in what order? All of the a then all of the b values? abab?

 as.vector(ys) and as.vector(t(ys)) will accomplish those.

 Or do you mean simply
 as- ys[1,]
 bs- ys[2,]

Thank you very much! That is what I was looking for. Sorry that I have 
expressed myself so unclear.


Greetings
Christof

__
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.


Re: [R] simplify source code

2011-12-01 Thread Christof Kluß

Hi

now I'd like to do

for (colname in c('ColName1','ColName2','ColName3')) {  
dat - measurements$colname

But that does not work, though I can write

measurements$C1 (same as measurements$C1)
(but different to measurements[C1]!)

Can you give me a hint?

greetings
Christof



Am 26-11-2011 23:30, schrieb Christof Kluß:

Hi

I would like to shorten

mod1 - nls(ColName2 ~ ColName1, data = table, ...)
mod2 - nls(ColName3 ~ ColName1, data = table, ...)
mod3 - nls(ColName4 ~ ColName1, data = table, ...)
...

is there something like

cols = c(ColName2,ColName3,ColName4,...)

for i in ...
mod[i-1] - nls(ColName[i] ~ ColName1, data = table, ...)

I am looking forward to help

Christof



__
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.


Re: [R] simplify source code

2011-11-29 Thread Christof Kluß

Hi Dennis,

thank you very much. That works fine.

Is there a possibility that R continue even if one of the models is not 
solvable? R currently terminates with an error message.


greetings
Christof


Am 27-11-2011 01:34, schrieb Dennis Murphy:

vars- c('y1', 'y2', 'y3')

# Function to create the model formula by plugging in the
# response y and run the model
mfun- function(y) {
  form- as.formula(paste(y, 'cbind(1, exp(x/th))', sep = ' ~ '))
  nls(form, data = dg, start = list(th = 0.3), algorithm = 'plinear')
 }

# Generate a list of model objects:
mlist- lapply(vars, mfun)


__
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.


Re: [R] append to PDF file

2011-11-29 Thread Christof Kluß

Hi Jim, Hi Ken

Am 27-11-2011 00:00, schrieb jim holtman:

There is the 'pdftk' (PDF tool kit) that you will find on the web that
will do the job.  I have used it to both combine and split out the
pages in the PDF file.


yes, thx. GUI tools like www.pdfsam.org do the job too. But is there a 
possibility to append files directly in R. That is to invoke pdftk 
inside R with a shellandwait?


perhaps something like

for (i in ...) {
  ...
  savePlot(filename=temp.pdf, type=pdf)
  exec pdftk temp.pdf final.pdf cat output final.pdf
}

greetings
Christof

__
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.


[R] simplify source code

2011-11-26 Thread Christof Kluß

Hi

I would like to shorten

mod1 - nls(ColName2 ~ ColName1, data = table, ...)
mod2 - nls(ColName3 ~ ColName1, data = table, ...)
mod3 - nls(ColName4 ~ ColName1, data = table, ...)
...

is there something like

cols = c(ColName2,ColName3,ColName4,...)

for i in ...
  mod[i-1] - nls(ColName[i] ~ ColName1, data = table, ...)

I am looking forward to help

Christof

__
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.


[R] append to PDF file

2011-11-26 Thread Christof Kluß

Hi

is there a way to append a plot as PDF to an existing PDF file?
savePlot seems not to have this possibility.

Christof

__
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.


[R] Fwd: linear regression with replication

2011-05-24 Thread Christof Kluß
Probably the question fits better in the lme4 mailing list, so I
forwarded it.

 Original-Nachricht 
Betreff: linear regression with replication
Datum: Mon, 23 May 2011 16:31:54 +0200
Von: Christof Kluß ckl...@email.uni-kiel.de
An: r-h...@stat.math.ethz.ch
Newsgruppen: gmane.comp.lang.r.general

Hi,

we want to calculate a linear regression that results from three test
series. (The Average linear regression over 3 replication.)
Each test serie consists of the values ​​for 3 times (0min, 25min,
50min) and is repeated three times.

We need such a regression for each combination of subject and day for a
file like this:

   subject time   date replication value
1A0 2011-01-01   1   0.2
2A   25 2011-01-01   1   0.3
3A   50 2011-01-01   1   0.4
4A0 2011-01-01   2   0.2
5A   25 2011-01-01   2   0.2
6A   50 2011-01-01   2   0.3
7A0 2011-01-01   3   0.3
8A   25 2011-01-01   3   0.4
9A   50 2011-01-01   3   0.5
... 2011-01-02  ...
... 2011-01-02  ...
2011-01-02
[...]
 B

Can you give us a hint how the R-file could look for this example? We
think that we should choose the library nlme and the command lme. We
are interested in the slope and intercept for each combination of
subject and date.

Greetings
Christof

__
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.

__
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.


[R] linear regression with replication

2011-05-23 Thread Christof Kluß
Hi,

we want to calculate a linear regression that results from three test
series. (The Average linear regression over 3 replication.)
Each test serie consists of the values ​​for 3 times (0min, 25min,
50min) and is repeated three times.

We need such a regression for each combination of subject and day for a
file like this:

   subject time   date replication value
1A0 2011-01-01   1   0.2
2A   25 2011-01-01   1   0.3
3A   50 2011-01-01   1   0.4
4A0 2011-01-01   2   0.2
5A   25 2011-01-01   2   0.2
6A   50 2011-01-01   2   0.3
7A0 2011-01-01   3   0.3
8A   25 2011-01-01   3   0.4
9A   50 2011-01-01   3   0.5
... 2011-01-02  ...
... 2011-01-02  ...
2011-01-02
[...]
 B

Can you give us a hint how the R-file could look for this example? We
think that we should choose the library nlme and the command lme. We
are interested in the slope and intercept for each combination of
subject and date.

Greetings
Christof

__
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.


[R] nonlinear regression with an iterativ function

2010-11-10 Thread Christof Kluß
Hi,

we have a function that calculates a value for each day of the year.

For example an iterative function like

actvalue_0 := 0
actvalue_ {t+1} := actvalue_t + f(param_1,param_2,actvalue_t)

and for some days we have measurements. Now we want to choose param_1
and param_2 so that the function values are close to our measured values.


Does anyone know how to solve this problem?

Thanks,
Christof

__
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.