Multiple "values"

15 views
Skip to first unread message

Igor Igor

unread,
Sep 4, 2024, 8:08:47 AM9/4/24
to json-stat
Hi.

The data are like:
Screenshot 2024-09-04 150451.png
Is it possible to have multiple "values" in the json-stat? I.e. not 7 files with "value" defined for each in [N, NMiss, ..., Varience] and same dimensions definition, but one file with single dimensions definition and multiple "values" in it?

Thank you in advance for clarification!


Simon Speich

unread,
Sep 4, 2024, 8:25:55 AM9/4/24
to json-stat
Yes, but you have to think of your "values" as an additional dimension of size 7 with categories (N, NMiss, ... , Variance).

Xavier Badosa

unread,
Sep 5, 2024, 3:35:22 AM9/5/24
to json...@googlegroups.com
Hello Igor,

In JSON-stat your dataset must be defined as Simon said.


--
You received this message because you are subscribed to the Google Groups "json-stat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to json-stat+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/json-stat/a7ca7f2e-6fb6-4c2f-b600-44477190b177n%40googlegroups.com.

Igor Igor

unread,
Sep 5, 2024, 3:51:51 AM9/5/24
to json-stat
Hi simon.
Thank you for answering. 
Am I correct assuming that instead of the above we will have the below?
Screenshot 2024-09-05 101517.png
As for N, Nmiss and Nobs that may work in some cases. But not sure about Mean, SD, SE, especially taking into account that they are derivatives varying too strongly between cases.
Because in most cases values of N, NMiss, ..., Varience are not known prior, that looks to be quite complicated even reasonable. 
Multiple "facts" are not comply with json-stat schema. So, looks, no chance to have it.

ChatGPT (GPT-4-latest) suggested (for 3 dimensions and 3 "values"):
Screenshot 2024-09-05 104006.png
Not properly formatted (missing id and size), but may be adjusted as necessary. The idea as for me promising (adding "fact" key with a structure as "dimension"). And making appropriate changes (extension) in schema, validator and convertors. 

Igor Igor

unread,
Sep 5, 2024, 3:54:46 AM9/5/24
to json-stat
Thank you Xavier. 

Yeh, understood. But in my case it will be more simple to have multiple files instead of having multiple not prior defined dimensions -- one per "fact". Or extend schema and make appropriate changes in json-stat readers to enable multiple facts. 

Igor Igor

unread,
Sep 5, 2024, 11:10:57 AM9/5/24
to json-stat
I finally understood how it may be presented by means of default schema thanks to :)
...
  "id": ["sex", "route", "var", "statistics"],
...
    "statistics": {
      "category": {
        "index": ["N", "mean", "sd"],
        "label": {
          "N": "total number", "mean": "arithmetic mean", "sd": "standard deviation"
        },
        "unit": {
          "N": {
            "decimals": 0
          },
          "mean": {
            "decimals": 2
          },
          "sd": {
            "decimals": 2
          }
        }
      }
    }

and "value" as an array.
I.e. wide-formatted table where  N, NMiss, ... , Variance are columns need to be converted to long-formatted table where these columns will be presented as values of the new column/dimension, let say "statistics". And all values will be in the "value"/measure array. 

Xavier Badosa

unread,
Sep 5, 2024, 11:14:18 AM9/5/24
to json...@googlegroups.com
The "value" structure suggested by GPT-4 is not a valid JSON-stat structure. One of the main principles of JSON-stat is that values are expressed in a flatten form because from the point of view of a cube dimensions are created equal. The "value" element can be an array

[25, 30, 7, 90...]

or an object of index/values (to address the sparse cube problem):

{ "0": 25, "1": 30, "2": 7, "3": 90... }

In valid JSON-stat you need a dimension for your stats (N, Nmiss, Nobs, Mean, etc.):

"dimensions": {
"sex": {
"category": {
"index": ["Male", "Female"]
}
},
"route": {
"category": {
"index": ["Oral", "Applicator", "Intravenous"]
}
},
"var": {
"category": {
"index": ["AUC3", "AUC6", "AUC12", "AUC24"]
}
},
"stat": {
"category": {
"index": ["N", "Nmiss", "NObs", "Mean", "SD", "SE", "Variance"]
}
}
}

From a JSON-stat structure you can "transpose" the data to get the structure

image.png

For example, using the JSON-stat JavaScript Toolkit you can use toTable() with a "by" dimension (in your example, "stat"), to get a JSON with the desired structure. Or with the JSON-stat JavaScript Utilities Suite you can get a CSV with the desired structure using toCSV() again with a "by". Or the command-line jsonstat2csv (with the --by option) included in the JSON-stat Command Line Conversion Tools (nodejs required).

Xavier

Xavier Badosa

unread,
Sep 5, 2024, 11:18:06 AM9/5/24
to json...@googlegroups.com
Exactly, that was what Simon was trying to say. I just replied with an example similar to yours.

X

Igor

unread,
Sep 6, 2024, 4:19:28 AM9/6/24
to json-stat
Simon,  Xavier.
Thank you so much for clarification!

Regards,
Igor.
Reply all
Reply to author
Forward
0 new messages