Skip to content

help to program my function

7 messages · Rui Barradas, hafida, PIKAL Petr

#
HI
http://r.789695.n4.nabble.com/file/n4639434/aj.pdf aj.pdf
+ n <- length(X)
+ iX <- order(X)
+ iz <- order(z)
+ e1 <- -(beta)*z[ iz[1:(i - 1)] ]
+ numer <- E[j] - sum( X[ iX[1:(i - 1)] ] * exp(e1) )
+ e2 <- -(beta)*z[ iz[i:n] ]
+ denom <- sum( exp(e2) )
+ numer/denom
+ }
[1] 75 37 29 60 73 20 69 55 30 70 72 38 26 35 65 61 74 50 71 57 25 54 64 76
56
[26] 58 48 67 46 63 28 62 36 49 47 66  1 42 41 19 39 43 22 51 68 33 27  9 15
11
[51] 10 59 32 40 45 44 52 16 18 34  4 53 21 23 31  7  6 13 14 12 17 24  5  8 
2
[76]  3
[1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
25
[26] 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
50
[51] 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
75
[76] 76
Warning message:
In 1:(i - 1) : numerical expression has 76 elements: only the first used
[1]  -442 -1664
Warning message:
In 1:(i - 1) : numerical expression has 76 elements: only the first used
[1] 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5
Warning message:
In i:n : numerical expression has 76 elements: only the first used
[1]  -442 -1664  -442 -1792  -476 -1792  -476 -1792  -510 -1920  -510 -1920
[13]  -510 -1920  -510 -1920  -510 -1920  -510 -2048  -544 -2048  -544 -2048
[25]  -544 -2048  -544 -2048  -544 -2048  -544 -2048  -544 -2048  -578 -2176
[37]  -578 -2176  -578 -2176  -578 -2176  -578 -2176  -578 -2176  -578 -2176
[49]  -578 -2176  -578 -2176  -578 -2304  -612 -2304  -612 -2304  -612 -2304
[61]  -612 -2304  -612 -2304  -612 -2304  -612 -2304  -646 -2432  -646 -2432
[73]  -646 -2432  -646 -2432
[1] 4.313746e+192 4.313746e+192 4.313746e+192 4.313746e+192 4.313746e+192
[6] 4.313746e+192 4.313746e+192 4.313746e+192
thank you in advance
hafida



--
View this message in context: http://r.789695.n4.nabble.com/help-to-program-my-function-tp4639434.html
Sent from the R help mailing list archive at Nabble.com.
#
Hello,

Your problem is something else, before returning a vector of only the 
same values there are warning messages.
Inline.

Em 07-08-2012 18:14, hafida escreveu:
This means that 'i' is a vector of length 76, which, in this context, is 
illegal. The variable 'i' must be a vector of only ONE value. If you 
want to compute the function for several (76) values do it one at a 
time, the function aj.fun is not vectorized.

Hope this helps,

Rui Barradas
#
Hi

Maybe it is time for you to read some basic stuff like R intro. It seems 
to me that you expect R to behave like some other language you know but 
probably your expectation is wrong.

See inline
where do you get beta
64 76
15
8
23 24
48 49
73 74
As somebody already mentioned i is probably vector and in this case only 
first value is taken. i seems to have the firs value 3.
Here j is vector of 8 values therefore 8 values
-1920
-2048
-2176
-2176
-2304
-2432
Strange, here first value of i seems to be 1 as n shall be 76 and final e2 
length is 76.
4.313746e+192
I do not understand. Your numer is 9.5 repeted 8 times. If you divide it 
by one number you will get nine times the same number.

You send us a code but no data so it is difficult to understand what is 
your goal. It would be better to send input data

j, i, X, z, E, beta0, beta1

and assumed result in whole not in chunks scattered in several mails.

Regards
Petr
http://www.R-project.org/posting-guide.html
#
Hi

please cc your post also to Rhelp list, others may give you better/quicker 
answer.
No pdf allowed.
2323.704
36
36
36
38
Use dput(your.data) and copy it to mail. It is directly redable by R and 
not scrambled like above.
Not at all. I did not help much yet.

Regards
Petr
9
5
used
used
e2
http://www.R-project.org/posting-guide.html
http://www.R-project.org/posting-guide.html
#
I am not allowed to connect to Nabble from work, sorry.

Petr
http://www.R-project.org/posting-guide.html