tag:blogger.com,1999:blog-4946490806848569840.comments2016-04-23T23:43:59.651-07:00R snippetsBogumił Kamińskinoreply@blogger.comBlogger186125tag:blogger.com,1999:blog-4946490806848569840.post-53430974543761589112016-04-23T23:43:59.651-07:002016-04-23T23:43:59.651-07:008 neighbors (so called Moore neighborhood)8 neighbors (so called Moore neighborhood)Bogumił Kamińskihttp://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-416654436706979362016-04-23T18:08:05.118-07:002016-04-23T18:08:05.118-07:00Hi! Thank you for your code. Can you tell me how y...Hi! Thank you for your code. Can you tell me how you define radius? If you have a radius of 1, is that a radius of 1 agent? And does that mean each agent has 4 neighbors (left, right, up, down) in their radius of 1 or 8 neighbors (left, right, up, down, plus 4 corner agents)?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-9259232590870566222016-01-07T05:00:21.578-08:002016-01-07T05:00:21.578-08:00You would have to pass a properly wrapped base fun...You would have to pass a properly wrapped base functions, eg. pass<br />function(x) mean(x, na.rm = TRUE)<br />as an argument.Bogumił Kamińskihttp://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-45796409628150005222016-01-07T04:34:13.050-08:002016-01-07T04:34:13.050-08:00Hi, this is very useful. But what if the data has ...Hi, this is very useful. But what if the data has missing or NA values? How can we modify the code in order to account for NA values?Manhal Mohammad Alihttp://www.blogger.com/profile/02627312280931410360noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-26619224729858180332015-05-31T18:55:18.042-07:002015-05-31T18:55:18.042-07:00Holy blog, THANK YOU so much, have a pleasant day ...Holy blog, THANK YOU so much, have a pleasant day :D kurnia sholihathttp://www.blogger.com/profile/10202633937791251852noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-87749976293063045702015-05-29T06:52:12.718-07:002015-05-29T06:52:12.718-07:00I have other approach. There is only one model:
m...I have other approach. There is only one model:<br /><br />model <- lm(formula(paste("y ~", piece.formula("x", knots))))<br /><br />but it has hinge variables at knots which you can check when you execute:<br /><br />paste("y ~", piece.formula("x", knots))<br /><br />to get the formula:<br /><br />"y ~ x + I(pmax(x + 0.666666666666667, 0)) + I(pmax(x + 0.333333333333333, 0)) + I(pmax(x - 0, 0)) + I(pmax(x - 0.333333333333333, 0)) + I(pmax(x - 0.666666666666667, 0))"<br /><br />and the final model is:<br /><br />Coefficients:<br /> Estimate Std. Error t value Pr(>|t|) <br />(Intercept) 6.559 2.197 2.986 0.00530 ** <br />x 5.865 2.690 2.180 0.03647 * <br />I(pmax(x + 0.666666666666667, 0)) -22.189 4.520 -4.909 2.41e-05 ***<br />I(pmax(x + 0.333333333333333, 0)) 27.239 4.179 6.518 2.12e-07 ***<br />I(pmax(x - 0, 0)) -7.775 4.164 -1.867 0.07080 . <br />I(pmax(x - 0.333333333333333, 0)) -14.905 4.179 -3.567 0.00113 ** <br />I(pmax(x - 0.666666666666667, 0)) 15.860 4.520 3.509 0.00132 ** <br />Bogumił Kamińskihttp://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-8719617301552114822015-05-29T03:15:02.844-07:002015-05-29T03:15:02.844-07:00Hi, thank you for the code, i find my knots much e...Hi, thank you for the code, i find my knots much easier using it, but i still don't understand how to find the models, if i have 2 knots, then shouldn't i have 3 models? Can you show me how to find the models using your code? Thank you very muchkurnia sholihathttp://www.blogger.com/profile/10202633937791251852noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-1505492409332568172015-01-31T00:09:41.551-08:002015-01-31T00:09:41.551-08:00You can start with learning parallel package.You can start with learning parallel package.Bogumił Kamińskihttp://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-25948653872085996502015-01-30T23:40:45.921-08:002015-01-30T23:40:45.921-08:00May I ask whether "sapply" is related to...May I ask whether "sapply" is related to parallel computing? I want to assign each subfunction to each core to compute the pvalues at the same time? Do you have any recommendation about that?Zhenchuan Wanghttp://www.blogger.com/profile/01825098384469325909noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-29366747241336304132015-01-30T23:22:44.197-08:002015-01-30T23:22:44.197-08:00I do not see your code, but my code works with sap...I do not see your code, but my code works with sapply. Probably you should replace it by other function appropriate for your case.Bogumił Kamińskihttp://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-64001703806379302962015-01-30T23:07:54.856-08:002015-01-30T23:07:54.856-08:00If I want to apply four methods (subfunctions) to ...If I want to apply four methods (subfunctions) to a same sample (matrix) to calculate the p-values. What should I do? I notice that your function is only available to vectors.Zhenchuan Wanghttp://www.blogger.com/profile/01825098384469325909noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-44985011419278527982015-01-09T06:39:00.528-08:002015-01-09T06:39:00.528-08:00Thx for the comment. However, notice that I use ==...Thx for the comment. However, notice that I use == only to show the results and it is clear that you would not use == in practice.<br /><br />But consider two things (as an example):<br />1) should it matter if you generate from low to hi or from hi to low (I would say it should not matter and in Python it does)<br />2) should you have your generated sequence as evenly spaced as possible (I would say yes and for example in R you have 'just beyond' that breaks this this assumption)Bogumił Kamińskihttp://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-58579104520839009552015-01-09T06:06:42.198-08:002015-01-09T06:06:42.198-08:00Hi,
well, maybe I miss the point, why you prefer ...Hi,<br /><br />well, maybe I miss the point, why you prefer Julia. Julia is giving 6 times "false" and R produces 6 times FALSE. Equal. The point is, however, that every programmer should consider using "==" or ".==" with floating point numbers to be bad und to be avoided. Python producing the most unexspected behaviour has the biggest chance, that the programmer notices a bug in his code before delivering or real-case using it. +1 for python. <br />Once you learned to avoid "==" with floats, the topic discussed here is of no relevance anymore (or, is it?).<br /><br />Greets,<br />BernhardAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-2272753680048336752015-01-07T23:57:44.587-08:002015-01-07T23:57:44.587-08:00If you are interested in details you can out this ...If you are interested in details you can out this discussion https://github.com/JuliaLang/julia/issues/9637.Bogumił Kamińskihttp://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-27451491312377446982015-01-07T10:46:49.343-08:002015-01-07T10:46:49.343-08:00Julia is designed by people who really cares about...Julia is designed by people who really cares about these kind of issues, so it uses a nice algorithm to make floating point ranges work more intuitively. You should still note that there are fundamental issues with binary floating point numbers and decimal literals in code, so it is probably possible to find edge cases in Julia too.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-71579535644957052882014-07-29T08:00:43.874-07:002014-07-29T08:00:43.874-07:00Thanks for the info and reply.Thanks for the info and reply.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-15444445065715588602014-07-29T03:28:17.225-07:002014-07-29T03:28:17.225-07:00I would use trapezoid rule for approximation of de...I would use trapezoid rule for approximation of definite integral with data points distributed uniformly (http://en.wikipedia.org/wiki/Trapezoidal_rule).<br />Note that there you should set x_1=f(x_1)=0 in order to get the left boundary of the integral.Bogumił Kamińskihttp://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-27184056434395023702014-07-28T07:07:09.184-07:002014-07-28T07:07:09.184-07:00I am looking for methods to calculate the area und...I am looking for methods to calculate the area under the Gain and Lift curves. The flux package has a method using the trapezoid rule (http://artax.karlin.mff.cuni.cz/r-help/library/flux/html/auc.html). What method would you use to add it to your Gain code above?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-71826263356371602862014-07-28T03:15:31.637-07:002014-07-28T03:15:31.637-07:00And what is your question?And what is your question?Bogumił Kamińskihttp://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-42345202379868227362014-07-28T03:05:54.825-07:002014-07-28T03:05:54.825-07:00Unfortunately the code given here does not support...Unfortunately the code given here does not support it directly.Bogumił Kamińskihttp://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-78528044471084165082014-07-28T01:36:37.665-07:002014-07-28T01:36:37.665-07:00how do i pass an additional variable along with th...how do i pass an additional variable along with the dataset being passedJERINhttp://www.blogger.com/profile/00652838277532965758noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-6922100791024010012014-07-27T18:05:00.072-07:002014-07-27T18:05:00.072-07:00I did find this: http://stats.stackexchange.com/qu...I did find this: http://stats.stackexchange.com/questions/24325/lorenz-curve-and-gini-coefficient-for-measuring-classifier-performance<br /><br />I will also be looking at calculating the area under the Gain curve as well... (http://www.saedsayad.com/model_evaluation_c.htm)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-21851288200133577722014-07-27T01:44:46.230-07:002014-07-27T01:44:46.230-07:00If I understand your question correctly you are as...If I understand your question correctly you are asking about the Gini coefficient.Bogumił Kamińskihttp://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-72511899188215168392014-07-26T17:22:05.822-07:002014-07-26T17:22:05.822-07:00Have you used Area Under Lift (AUL), analogous to ...Have you used Area Under Lift (AUL), analogous to AUC, for model evaluation/comparison? Do you have suggestions on an approach for calculating AUL?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4946490806848569840.post-67383569096894642542014-06-16T02:33:05.096-07:002014-06-16T02:33:05.096-07:00Well, that is another reason why you should always...Well, that is another reason why you should always use full argument names. Under R 3.0.1 "scan" doesn't have "skipNul" argument.Bartek Chrołnoreply@blogger.com