harmonic mean

19 views
Skip to first unread message

Ayala Allon

unread,
May 7, 2013, 7:27:58 AM5/7/13
to israel-r-...@googlegroups.com
שלום,
 
האם מישהו מכיר חבילה שיש בה פונקציה שמחשבת
harmonic mean?
וגם האם יש פונקציה שמחשבת רבעונים ו/או פרסנטילות?
 
תודה
אילה

Jonathan Rosenblatt

unread,
May 7, 2013, 7:30:44 AM5/7/13
to israel-r-...@googlegroups.com
Harmonic mean:
1/mean(1/x)

Quantiles:
quantile( )

--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-g...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Jonathan Rosenblatt
www.john-ros.com

Ayala Allon

unread,
May 22, 2013, 3:24:24 PM5/22/13
to israel-r-...@googlegroups.com

היי

תודה על התשובה.

יש לי בעיה שנכון לעכשיו אני לא מצליחה לפתור:

אני מנסה להשתמש בפונקציה quantile( ) יחד עם tapply אבל אני לא מצליחה לקבל את מה שאני רוצה.

יש לי קובץ תוצאות בצורת טבלה (בפורמט של CSV) מניסוי. כל נבדק עבר 4 תנאים ובכל תנאי הוא עשה 45 טריילים, סה"כ 180 טריילים עבור כל נבדק (המספר לא ממש משנה לעניינינו כרגע, אני רק מנסה להסביר איך הטבלה בנויה). המדד התלוי שלי הוא זמן תגובה. זה אומר שיש לי טבלה עם 180*15 שורות (כי יש לי 15 נבדקים), ו-4 טורים (אחד עבור כל תנאי).

מה שכבר הצלחתי לעשות זה לחשב עבור כל נבדק ממוצע (וגם חציון, סטיית תקן ועוד פרמטרים) עבור כל תנאי, כך שתהיה לי טבלה עם 15 שורות ו-4 טורים, כאשר בכל תא בטבלה יש לי את הממוצע של הנבדק עבור התנאי או כל פרמטר אחר שחישבתי.

אני רוצה לעשות אותו הדבר רק במקום לחשב ממוצע עבור כל נבדק עבור כל תנאי, אני רוצה לחשב את הערך ברבעון הראשון והשלישי, פרסנטילות שונות וכו'.

ניסיתי להשתמש ב-

tapply(rt_data$rt,list(rt_data$subject,rt_data$condition),quantile)

אבל זה נותן לי את הטבלה הבאה:

     1_1       1_2       2_1       2_2      

5013 Numeric,5 Numeric,5 Numeric,5 Numeric,5

5020 Numeric,5 Numeric,5 Numeric,5 Numeric,5

5021 Numeric,5 Numeric,5 Numeric,5 Numeric,5

5022 Numeric,5 Numeric,5 Numeric,5 Numeric,5

5023 Numeric,5 Numeric,5 Numeric,5 Numeric,5

5024 Numeric,5 Numeric,5 Numeric,5 Numeric,5

5101 Numeric,5 Numeric,5 Numeric,5 Numeric,5

5102 Numeric,5 Numeric,5 Numeric,5 Numeric,5

5104 Numeric,5 Numeric,5 Numeric,5 Numeric,5

5105 Numeric,5 Numeric,5 Numeric,5 Numeric,5

5106 Numeric,5 Numeric,5 Numeric,5 Numeric,5

5107 Numeric,5 Numeric,5 Numeric,5 Numeric,5

5108 Numeric,5 Numeric,5 Numeric,5 Numeric,5

5109 Numeric,5 Numeric,5 Numeric,5 Numeric,5

5110 Numeric,5 Numeric,5 Numeric,5 Numeric,5

 

למישהו יש רעיון מה אני יכולה לעשות כדי לקבל את הערך שאני רוצה בכל תא?

תודה רבה על העזרה 

אילה

On Tuesday, May 7, 2013 5:30:44 AM UTC-6, Jonathan Rosenblatt wrote:
Harmonic mean:
1/mean(1/x)

Quantiles:
quantile( )

On Tue, May 7, 2013 at 2:27 PM, Ayala Allon <ayala...@gmail.com> wrote:
שלום,
 
האם מישהו מכיר חבילה שיש בה פונקציה שמחשבת
harmonic mean?
וגם האם יש פונקציה שמחשבת רבעונים ו/או פרסנטילות?
 
תודה
אילה

--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-group+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Jonathan Rosenblatt
www.john-ros.com

Tal Galili

unread,
May 22, 2013, 3:30:21 PM5/22/13
to israel-r-...@googlegroups.com
כמה אופציות,
1) ללמוד להשתמש בחבילה plyr או reshape.
2) לעשות פונקציות נפרדות לאחוזונים השונים שמעניינים אותך (תוך כדי שימוש בפרמטר ההסתברות של האחוזון), לדוגמא:

x <- 1:10
ind <- rep(c(1,2), times = 5)
tapply(x, ind, mean)

tapply(x, ind, quantile, probs = 0.8)
דוגמא לאופציה 1:


require(plyr)
xx <- data.frame(x, ind)
ddply(xx, .(ind), function(xx) {quantile(xx$x)})




2013/5/22 Ayala Allon <ayala...@gmail.com>

ן לעכשיו אני לא מצליחה לפתור:

אני מנסה להשתמ





----------------Contact Details:-------------------------------------------------------
Contact me: Tal.G...@gmail.com
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English)
----------------------------------------------------------------------------------------------

amit gal

unread,
May 22, 2013, 3:46:01 PM5/22/13
to israel-r-...@googlegroups.com
רק כדי להרחיב על הפתרון שטל מצביע: הפונקציה quantile מחזירה בברירת המחדל 5 ערכים, ולכן במטריצה שקיבלת בtapply שלך יש בכל תא 5 ערכים, שזה משהו שאפשר להתמודד איתו, אבל זה מורכב יותר, ובוודאי לא מייצר מטריצת נתונים פשוטה שאפשר אחר כך להשתמש בה לניתוחים סטטיסטיים. הפתרון הראשון שטל הציע הוא פשוט להעביר לפונקציה quantile שמופעלת בתוך הtapply, פרמטר שמשנה את ההתנהגות הבסיסית שלה (בדוגמה שלו, probs=0.8 אומר שיוחזר האחוזון ה80 בלבד, כלומר ערך בודד לכל תא במטריצה. אם את צריכה שניים או יותר, הייתי מייצר כמה מטריצות ואח"כ מחבר אותן, עדיף באמצעות merge מתאים.
את הויכוח למה אני פחות אוהב את הפתרון השני של טל (שהוא נכון ומדויק) נשאיר לדיון אחר :)





2013/5/22 Tal Galili <tal.g...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-g...@googlegroups.com.

Tal Galili

unread,
May 22, 2013, 3:51:40 PM5/22/13
to israel-r-...@googlegroups.com
עמית, סבבה, אם אתה מתעקש, הנה פתרון נוסף:
(tmp <- tapply(x, ind, quantile, simplify =FALSE))
do.call("rbind", tmp)




----------------Contact Details:-------------------------------------------------------
Contact me: Tal.G...@gmail.com
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English)
----------------------------------------------------------------------------------------------



2013/5/22 amit gal <amit...@gmail.com>

amit gal

unread,
May 22, 2013, 3:59:32 PM5/22/13
to israel-r-...@googlegroups.com
עכשיו זה סתם לא מועיל - הtapply שלה היה "דו מימדי", ואז הפתרון שלך פשוט לא נכון - כי הוא מאבד לחלוטין את המידע לאיזה טור ושורה בטבלה כל מספר מתייחס



2013/5/22 Tal Galili <tal.g...@gmail.com>

Tal Galili

unread,
May 22, 2013, 4:22:47 PM5/22/13
to israel-r-...@googlegroups.com
הבאתי פיתרון בסיסי לבעיה שהוצגה. למקרה דו ממדי, אני חוזר על המלצתי לגבי reshape

Sent from my iPhone

Ayala Allon

unread,
May 22, 2013, 10:46:27 PM5/22/13
to israel-r-...@googlegroups.com
תודה רבה לכולם על התשובות וההסברים. הוספת הפרמטר probs ויצרת כמה טבלאות ואז לאחד אותם יעשה את זה העבודה.

אילה


2013/5/22 Tal Galili <tal.g...@gmail.com>
2013/5/22 amit gal <amit...@gmail.com>


2013/5/22 Tal Galili <tal.g...@gmail.com>
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-group+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-group+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-group+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-group+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages