asjadnaqvi / stata-spider

spider: A Stata package for spider plots.
MIT License
12 stars 1 forks source link

Option smooth not working #1

Closed feynmantrap closed 1 year ago

feynmantrap commented 2 years ago

Dear Asjad,

First of all. Thank you so much for creating this package. I am constantly using spider plots but always found Stata's radar plot unattractive.

I am writing to you because I just tried your package for the first time and when I use the option Smooth I always get an error message saying "variable _m not found"

This only appears when running smooth.

Hope you can help ( :

Thanks in advance!

asjadnaqvi commented 2 years ago

check now

feynmantrap commented 2 years ago

Hello, thanks for the answer.

Sadly, the bug remains.

I am using Stata/SE 17 for Mac M1. I am just running this line of code: spider days_individual_treatment, over(inf_localisation_string) ra(10 50) cuts(5) smooth(0.5)

Everything always works except if the smooth options is there, keep getting the same error:

Screenshot 2022-11-08 at 08 43 45
asjadnaqvi commented 2 years ago

That is strange! I checked with completely other data and it works. So there is something else going on that needs to be bug fixed.

If possible can you send me the data please and I will check. Curious to see where it get's stuck.

feynmantrap commented 2 years ago

Hello, thanks for the prompt response.

I am sending a random sample with both variables that I am trying to plot. Hope this is enough ( :

Let me know if you need further materials. 2022_11_08_test_data_spider.csv

asjadnaqvi commented 2 years ago

I tested and it's working fine on PC.

net install spider, from("https://raw.githubusercontent.com/asjadnaqvi/stata-spider/main/installation/") replace

import delim 2022_11_08_test_data_spider.csv, encoding("UTF-8") clear

spider days_individual_treatment, over(inf_localisation_string) ra(10 30) cuts(5) smooth(0.5)
graph export spider1.png, replace wid(1200)

collapse (mean) mean=days_individual_treatment (p25) p25=days_individual_treatment (p75) p75=days_individual_treatment, by(inf_localisation_string) 

spider mean p25 p75, over(inf_localisation_string) ra(0 60) cuts(7) smooth(0.1)
graph export spider2.png, replace wid(1200)

spider1 spider2

feynmantrap commented 2 years ago

Hello, thank you so much.

Smooth options is working with no problems now. However, after trying your code I get an error message queen plating: variable _merge already defined. Screenshot 2022-11-08 at 17 08 59

asjadnaqvi commented 2 years ago

Do you already have a _m in the dataset?!

This is the only thing I think which might be causing an issue. I will add some more checks for the existence of the merge variable.

feynmantrap commented 2 years ago

Hello

No _m, or _merge on my data set. It's weird. Even dropped every variable and just kept the two variables I needed, and still I get the error.

However, If I run try to plot after collapse only by mean It works, is the p25 and p75 that are giving the problem.

I also did some checks in the whole data set. I can't found a reason unless is something related to Stata functioning in Apple M1?

Update: I just

Screenshot 2022-11-09 at 10 11 03
feynmantrap commented 2 years ago

Sorry for a second message. But, after collapsing I can plot mean or p25 or p75 only individually. Problem comes when I try to plot more than one measurement.

spider mean, over(inf_localisation_string) ra(0 60) cuts(5) smooth(0.1) Graph_mean.pdf

spider p25, over(inf_localisation_string) ra(0 60) cuts(5) smooth(0.1) Graph_p25.pdf

spider mean p25, over(inf_localisation_string) ra(0 60) cuts(5) smooth(0.1)

Screenshot 2022-11-09 at 10 22 21
asjadnaqvi commented 2 years ago

Check the new version please. The program now just drops all the unrelated variables in the background. So hopefully no more _m issues.

feynmantrap commented 2 years ago

No, sorry. I downloaded the new version, however, I keep getting the same error. I understand it is frustrating.

Let me know if there are more details you need. Especially Mac related. Do you have people reporting the same issue?

feynmantrap commented 1 year ago

Hello,

Just a quick follow-up.

I was using the package for another project.

It seems that is a Stata for Apple related problem. Shortly: if you use merge, mmerge, collapse or reshape in your code, spider does not work and always shows the same error: _r(110) merge previously defined. However, this only happens if I want to plot > 1 variable.

I ran exactly the same code in Stata for windows and the problem does not exist.

Note aside: do you think is possible to add a by() option? In my data set (which is long, but I have different visits numbered for patients) that would avoid doing reshape or whatever to go for wide. i.e: spider var1 var2 var3 by(visit), over(group) alpha(0) smooth(0.5).

Thank you so much, I am using a lot your packages, sadly this is the only one giving problems which is kind of frustrating.

Happy festivities!

Best,

José

asjadnaqvi commented 1 year ago

Dear Jose, thank you for the update!

I will add more controls to check for variations in merge variables.

Regarding by(), others have requested it as well. I will try and incorporate it in the next update.

asjadnaqvi commented 1 year ago

Supporting by() added as a new issue in #2.